1. How to deploy Azure Cosmos DB MongoDB Collection?

    TypeScript

    The azure-native package contains the MongoDBResourceMongoDBCollection resource. An instance of it represents a MongoDB collection within a database under an Azure Cosmos DB account.

    This is a representation of the properties you may assign while creating an MongoDBResourceMongoDBCollection resource.

    import * as pulumi from "@pulumi/pulumi"; import * as azure_native from "@pulumi/azure-native"; new azure_native.documentdb.MongoDBResourceMongoDBCollection("exampleCollection", { accountName: "cosmosAccountName", databaseName: "databaseName", resource: { id: "collectionName", shardKey: { '<shardKeyName>': "Hash" // Shard Key must be an existing attribute in the data. }, options: { throughput: 400 // RU/s } }, collectionName: "example", resourceGroupName: "resourceGroupName", });

    In the above code:

    • accountName specifies the Cosmos DB account name.
    • databaseName is the name of the database in which you're creating the collection.
    • resource is an object that represents the properties of the Cosmos DB MongoDB collection.
      • id is the name of the Cosmos DB MongoDB collection.
      • shardKey is a key-value pair of shard keys to be applied for the request.
      • options is an object, where you can set the desired throughput for the collection.
    • collectionName provides a name for the MongoDB collection.
    • resourceGroupName should correspond to the resource group where the Cosmos DB account resides.

    Replace the values in <> with your actual values. For example, replace <shardKeyName> with the name that you want to use as your shard key.

    Please note that, before you can create a Cosmos DB MongoDB Collection, you should have a Cosmos DB account and a MongoDB Database created.

    Check this link for more details on the MongoDBResourceMongoDBCollection class: Azure Pulumi Docs