
Azure Cosmos DB Manager
FreeProvision and manage Azure Cosmos DB resources with .NET.
Free · Opens the source repo
What Azure Cosmos DB Manager does
The Azure.ResourceManager.CosmosDB SDK provides a management plane interface for provisioning and managing Azure Cosmos DB resources using .NET. This SDK allows developers to create and configure Cosmos DB accounts, databases, and containers, as well as manage throughput settings and role-based access control (RBAC). It is designed for developers who need to automate the management of Cosmos DB resources as part of their Azure infrastructure.
To get started, developers can install the SDK via NuGet packages and authenticate using Azure's DefaultAzureCredential. This ensures secure access to Azure resources without hardcoding sensitive information. The SDK supports a range of operations, including account creation, database and container management, and throughput configuration, making it a comprehensive tool for developers working with Azure Cosmos DB.
The SDK distinguishes between management plane operations and data plane operations, allowing users to focus on provisioning and configuration tasks without interfering with data manipulation operations that are handled by the separate Microsoft.Azure.Cosmos SDK. This separation of concerns simplifies the development process and enhances the clarity of the codebase.
Developers looking to streamline their Azure Cosmos DB management tasks will find this SDK particularly useful. It is suitable for both small-scale projects and larger applications where automated resource management is essential for efficiency and scalability.
When to use it
Use this skill when you need to automate the provisioning and management of Azure Cosmos DB resources in your .NET applications.
When not to use it
This SDK is not suitable for performing CRUD operations on documents or executing queries, as those tasks are handled by the separate data plane SDK.
What you can build with it
Automating Resource Provisioning
Use the SDK to automate the creation of Cosmos DB accounts and databases as part of your CI/CD pipeline.
Managing Throughput Settings
Easily adjust the throughput settings for your Cosmos DB resources based on application demand.
Implementing RBAC
Manage role-based access control for your Cosmos DB resources programmatically to enhance security.
How to install Azure Cosmos DB Manager
View source1. Install with the skills CLI
npx skills add sickn33/agentic-awesome-skills/azure-resource-manager-cosmosdb-dotnet --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by sickn33Azure.ResourceManager.CosmosDB (.NET)
Management plane SDK for provisioning and managing Azure Cosmos DB resources via Azure Resource Manager.
⚠️ Management vs Data Plane
- This SDK (Azure.ResourceManager.CosmosDB): Create accounts, databases, containers, configure throughput, manage RBAC
- Data Plane SDK (Microsoft.Azure.Cosmos): CRUD operations on documents, queries, stored procedures execution
Installation
dotnet add package Azure.ResourceManager.CosmosDB
dotnet add package Azure.Identity
Current Versions: Stable v1.4.0, Preview v1.4.0-beta.13
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id>
# For service principal auth (optional)
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>
Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.CosmosDB;
// Always use DefaultAzureCredential
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
// Get subscription
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var subscription = armClient.GetSubscriptionResource(
new ResourceIdentifier($"/subscriptions/{subscriptionId}"));
Resource Hierarchy
ArmClient
└── SubscriptionResource
└── ResourceGroupResource
└── CosmosDBAccountResource
├── CosmosDBSqlDatabaseResource
│ └── CosmosDBSqlContainerResource
│ ├── CosmosDBSqlStoredProcedureResource
│ ├── CosmosDBSqlTriggerResource
│ └── CosmosDBSqlUserDefinedFunctionResource
├── CassandraKeyspaceResource
├── GremlinDatabaseResource
├── MongoDBDatabaseResource
└── CosmosDBTableResource
Core Workflow
1. Create Cosmos DB Account
using Azure.ResourceManager.CosmosDB;
using Azure.ResourceManager.CosmosDB.Models;
// Get resource group
var resourceGroup = await subscription
.GetResourceGroupAsync("my-resource-group");
// Define account
var accountData = new CosmosDBAccountCreateOrUpdateContent(
location: AzureLocation.EastUS,
locations: new[]
{
new CosmosDBAccountLocation
{
LocationName = AzureLocation.EastUS,
FailoverPriority = 0,
IsZoneRedundant = false
}
})
{
Kind = CosmosDBAccountKind.GlobalDocumentDB,
ConsistencyPolicy = new ConsistencyPolicy(DefaultConsistencyLevel.Session),
EnableAutomaticFailover = true
};
// Create account (long-running operation)
var accountCollection = resourceGroup.Value.GetCosmosDBAccounts();
var operation = await accountCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-cosmos-account",
accountData);
CosmosDBAccountResource account = operation.Value;
2. Create SQL Database
var databaseData = new CosmosDBSqlDatabaseCreateOrUpdateContent(
new CosmosDBSqlDatabaseResourceInfo("my-database"));
var databaseCollection = account.GetCosmosDBSqlDatabases();
var dbOperation = await databaseCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-database",
databaseData);
CosmosDBSqlDatabaseResource database = dbOperation.Value;
3. Create SQL Container
var containerData = new CosmosDBSqlContainerCreateOrUpdateContent(
new CosmosDBSqlContainerResourceInfo("my-container")
{
PartitionKey = new CosmosDBContainerPartitionKey
{
Paths = { "/partitionKey" },
Kind = CosmosDBPartitionKind.Hash
},
IndexingPolicy = new CosmosDBIndexingPolicy
{
Automatic = true,
IndexingMode = CosmosDBIndexingMode.Consistent
},
DefaultTtl = 86400 // 24 hours
});
var containerCollection = database.GetCosmosDBSqlContainers();
var containerOperation = await containerCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"my-container",
containerData);
CosmosDBSqlContainerResource container = containerOperation.Value;
4. Configure Throughput
// Manual throughput
var throughputData = new ThroughputSettingsUpdateData(
new ThroughputSettingsResourceInfo
{
Throughput = 400
});
// Autoscale throughput
var autoscaleData = new ThroughputSettingsUpdateData(
new ThroughputSettingsResourceInfo
{
AutoscaleSettings = new AutoscaleSettingsResourceInfo
{
MaxThroughput = 4000
}
});
// Apply to database
await database.CreateOrUpdateCosmosDBSqlDatabaseThroughputAsync(
WaitUntil.Completed,
throughputData);
5. Get Connection Information
// Get keys
var keys = await account.GetKeysAsync();
Console.WriteLine($"Primary Key: {keys.Value.PrimaryMasterKey}");
// Get connection strings
var connectionStrings = await account.GetConnectionStringsAsync();
foreach (var cs in connectionStrings.Value.ConnectionStrings)
{
Console.WriteLine($"{cs.Description}: {cs.ConnectionString}");
}
Key Types Reference
| Type | Purpose |
|---|---|
ArmClient | Entry point for all ARM operations |
CosmosDBAccountResource | Represents a Cosmos DB account |
CosmosDBAccountCollection | Collection for account CRUD |
CosmosDBSqlDatabaseResource | SQL API database |
CosmosDBSqlContainerResource | SQL API container |
CosmosDBAccountCreateOrUpdateContent | Account creation payload |
CosmosDBSqlDatabaseCreateOrUpdateContent | Database creation payload |
CosmosDBSqlContainerCreateOrUpdateContent | Container creation payload |
ThroughputSettingsUpdateData | Throughput configuration |
Best Practices
- Use
WaitUntil.Completedfor operations that must finish before proceeding - Use
WaitUntil.Startedwhen you want to poll manually or run operations in parallel - Always use
DefaultAzureCredential— never hardcode keys - Handle
RequestFailedExceptionfor ARM API errors - Use
CreateOrUpdateAsyncfor idempotent operations - Navigate hierarchy via
Get*methods (e.g.,account.GetCosmosDBSqlDatabases())
Error Handling
using Azure;
try
{
var operation = await accountCollection.CreateOrUpdateAsync(
WaitUntil.Completed, accountName, accountData);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
Console.WriteLine("Account already exists");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");
}
Reference Files
| File | When to Read |
|---|---|
| references/account-management.md | Account CRUD, failover, keys, connection strings, networking |
| references/sql-resources.md | SQL databases, containers, stored procedures, triggers, UDFs |
| references/throughput.md | Manual/autoscale throughput, migration between modes |
Related SDKs
| SDK | Purpose | Install |
|---|---|---|
Microsoft.Azure.Cosmos | Data plane (document CRUD, queries) | dotnet add package Microsoft.Azure.Cosmos |
Azure.ResourceManager.CosmosDB | Management plane (this SDK) | dotnet add package Azure.ResourceManager.CosmosDB |
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Frequently asked questions about Azure Cosmos DB Manager
Similar skills
WinMD API Search
Easily find and explore Windows desktop APIs.
WebMCPify
Transform any web app into an agent-ready platform.
Phoenix Tracing
Instrument LLM applications with OpenInference tracing.
Foundry Hosted Agent CopilotKit
Guidance for developing agentic web apps on Azure.
Power Automate Foundation
Connect AI agents to Power Automate seamlessly.
Power Automate Flow Builder
Efficiently build and deploy Power Automate flows programmatically.
