Provision and Manage Azure Cosmos DB Resources
.NET management-plane SDK for Azure Cosmos DB - provision accounts, databases, containers, and throughput via ARM.
Why it matters
Automate the provisioning and management of Azure Cosmos DB resources, including accounts, databases, and containers, using the .NET SDK. This asset enables efficient infrastructure as code for your NoSQL database deployments.
Outcomes
What it gets done
Create and configure Azure Cosmos DB accounts.
Define and deploy SQL databases and containers.
Manage throughput settings for databases and containers.
Retrieve connection strings and keys for Cosmos DB accounts.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-azure-resource-manager-cosmosdb-dotnet | bash Overview
Azure.ResourceManager.CosmosDB (.NET)
A .NET SDK reference for provisioning Azure Cosmos DB infrastructure through Azure Resource Manager - accounts, SQL databases and containers, and throughput configuration. Use when provisioning or reconfiguring Cosmos DB infrastructure itself from .NET, not for document CRUD or queries against an existing container.
What it does
Azure.ResourceManager.CosmosDB is the .NET management-plane SDK for Azure Cosmos DB: it provisions and configures accounts, databases, containers, and throughput through Azure Resource Manager, in contrast to the data-plane SDK Microsoft.Azure.Cosmos, which handles document CRUD, queries, and stored-procedure execution once a container already exists. Its resource model mirrors ARM's hierarchy: ArmClient to SubscriptionResource to ResourceGroupResource to CosmosDBAccountResource, which in turn owns CosmosDBSqlDatabaseResource (and its CosmosDBSqlContainerResource, stored procedures, triggers, UDFs) plus Cassandra, Gremlin, MongoDB, and Table API equivalents.
When to use - and when NOT to
Use this skill when provisioning or reconfiguring Cosmos DB infrastructure itself - creating an account with a chosen consistency level and failover setup, creating SQL databases and containers with partition keys and indexing policies, or switching a database between manual and autoscale throughput. It is not for reading or writing documents, running queries, or executing stored procedures against an existing container - that is Microsoft.Azure.Cosmos's job.
Inputs and outputs
Every create/update call takes a strongly-typed content object - CosmosDBAccountCreateOrUpdateContent (location, per-region locations with failover priority and zone redundancy, Kind, ConsistencyPolicy, EnableAutomaticFailover), CosmosDBSqlDatabaseCreateOrUpdateContent, or CosmosDBSqlContainerCreateOrUpdateContent (partition key path and kind, indexing policy, DefaultTtl) - and returns the created resource object via operation.Value after a long-running operation completes. Throughput is set via ThroughputSettingsUpdateData, either manual (Throughput = 400) or autoscale (AutoscaleSettings.MaxThroughput = 4000). Connection details come from account.GetKeysAsync() (PrimaryMasterKey) and account.GetConnectionStringsAsync() (a list of named connection strings).
dotnet add package Azure.ResourceManager.CosmosDB
dotnet add package Azure.Identity
Integrations
Authenticates exclusively via DefaultAzureCredential from Azure.Identity - the skill's own best practices say never to hardcode keys. Long-running operations accept WaitUntil.Completed (block until finished) or WaitUntil.Started (return immediately for manual polling or parallel work), and every resource level exposes Get* methods (e.g. account.GetCosmosDBSqlDatabases()) for navigating down the hierarchy. RequestFailedException carries ARM error details - the skill's error-handling example specifically catches status 409 to report an already-existing account separately from a generic ARM failure, which surfaces the response's Status, ErrorCode, and Message. CreateOrUpdateAsync is recommended for idempotent provisioning, since re-running it against an existing resource updates rather than fails outright.
Who it's for
.NET developers and platform teams provisioning or automating Cosmos DB infrastructure as code - creating accounts with specific consistency and failover settings, defining containers with the right partition key and TTL, and moving databases between manual and autoscale throughput - as distinct from application developers who only need to read and write documents through the data-plane SDK.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.