I will show you two ways to deploy azure CosmosDb artefacts.
Cosmos SDKs for SQL API
The SDK name maybe confuses people, but you can use this SDK for all CosmosDB APIs (Cassandra API has issues with throughput). I think they will change this soon, because the prerelease Nuget Package already is named
Microsoft Azure Cosmos.
It can do 2 things:
- Create CosmosDb artefacts (Db/collection/documents) - not a CosmosDb account
- Query CosmosDb documents
//create the database with throughput string databaseName = "MyDatabaseName"; await this.cosmosClient.CreateDatabaseIfNotExistsAsync( id: databaseName, throughput: 400);
// Create a container with a partition key and provision throughput of 1000 RU/s string containerName = "myContainerName"; string partitionKeyPath = "/myPartitionKey"; await this.cosmosClient.GetDatabase("myDatabase").CreateContainerAsync( id: containerName, partitionKeyPath: partitionKeyPath, throughput: 1000);
Azure libraries for .Net
This is the general library for deploying Azure resources and can't query any documents from CosmosDb. It's can only create azure resources.
Following CosmosDB artefacts can be created (+ nearly all azure artefacts):
- CosmosDB account
- CosmosDB database
- CosmosDB collection
Here you can find some samples for creating these artefacts with configured throughput: https://developers.de/2020/03/12/mongo-cosmosdb-deploy-with-throughput/