/documentdb:documentdb-azure-deploymentfrom documentdb
Provisions Azure DocumentDB (MongoDB-compatible) clusters via Bicep, Azure CLI, Terraform, or portal. Covers resource groups, cluster parameters, firewall rules, connection strings, and teardown.
Ships in documentdb. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Interactive skill for provisioning a managed Azure DocumentDB cluster (resource type Microsoft.DocumentDB/mongoClusters, API 2026-06-01). Azure DocumentDB is the managed Azure service built on the open-source microsoft/documentdb engine.
For running DocumentDB locally instead (Docker / Compose), use documentdb-local-deployment. For connection-string tuning after the cluster exists, use documentdb-connection.
Easy to mix up
- CLI: Azure DocumentDB (with MongoDB compatibility) uses
az documentdb mongocluster, from thedocumentdbextension (check prerequisites only in deploy mode below). The olderaz cosmosdb mongoclustercommands in thecosmosdb-previewextension date from before the service was renamed; don't use them for new work.- API version: use
2026-06-01for new templates. Many older samples and blog posts use2024-07-01.- Portal and scripts: the portal is a good way to look around, but every step below also has a command. Use the commands for anything you want to repeat, review, or automate.
Choose author-only or deploy from the user's request before any preflight. A request for IaC/files/a plan is author-only, not permission to deploy. If execution intent is unclear, ask; meanwhile stay author-only.
Skip Step 0 and all execution steps. Read local reference templates, write placeholder infrastructure/parameter files and a README, then stop. Missing tools, login, subscription, or network access must not block file authoring.
The checked-in examples are references for
file authoring, not permission to execute deploy.sh or deploy.ps1.
Choose Bicep, Azure CLI, Terraform, or portal using the Step 5 table before checking tools. Confirm the intended subscription, resource group, region, resource changes, and costs before executing writes. A deployment request does not waive the later input, secret-handling, firewall, or teardown confirmations. What-if is a cloud operation, not offline validation: obtain separate approval and the required permissions. An existing login or resource group is not approval for what-if.
Only after an explicit deployment request and path selection, check the relevant local versions (read-only); do not require every tool for every path:
| Selected path | Local checks |
|---|---|
| Bicep via Azure CLI | az version; az bicep version |
| Azure CLI one-shot | az version; az extension show --name documentdb (the extension requires Azure CLI 2.75.0 or later) |
| Terraform | terraform -version; az version only if using Azure CLI authentication |
| Portal | No local CLI prerequisites |
Report missing tools or incompatible versions and ask before any installation
or upgrade. Never use check || install, auto-upgrade, or silently fix it in
place. The extension's CLI minimum is not a blanket requirement for Bicep-only
or portal authoring. Do not run Terraform init/plan/apply as a version check.
For the selected command-line path, inspect the relevant signed-in identity and Azure state only with the user's authorization:
# Read-only checks; use only those relevant to the selected path and scope.
az account show --query '{name:name, id:id}' -o json
az provider show --namespace Microsoft.DocumentDB --query registrationState -o tsv
az provider show --namespace Microsoft.DocumentDB \
--query "resourceTypes[?resourceType=='mongoClusters'].locations[]" -o tsv
If login, subscription switching, or provider registration is needed, explain
and obtain approval before doing it; do not automatically repair failures.
Confirm the caller has the required permissions on the intended target scope
(for example, Microsoft.DocumentDB/mongoClusters/write to create a cluster).
Missing permissions mean stop and ask the authorized operator, not grant roles.
Use Steps 1–3 to confirm subscription, resource group, and region before writes.
examples/azure-deployment/deploy.sh and deploy.ps1 can log in, register the
provider, and create a resource group automatically. Review those effects and
obtain explicit approval before running them; never run them in author-only mode.
Ask the user before anything else in Step 1. The answer drives every default. Never assume.
| If "production" (default) | If "dev / prototype / test" |
|---|---|
| Tier: M30 (minimum that supports HA) | Tier: M10 or M20 |
| Storage: 128 GiB per shard | Storage: 32 GiB |
| HA: ZoneRedundantPreferred | HA: Disabled |
Firewall: Private Endpoint; allowAzureServices: false | allowAzureServices: true + developer IP rule |
| Password source: Key Vault reference | Key Vault preferred; literal OK for throwaway |
Parameters file: main.parameters.sample.json | main.parameters.dev.json |
Production is the safer default — the Bicep template and main.parameters.sample.json in examples/azure-deployment/ ship with M30 + ZoneRedundantPreferred + 128 GiB so that a customer who runs ./deploy.sh <rg> <location> without overrides ends up with a cluster they can actually put workloads on. If the user answers "dev", either:
--parameters @main.parameters.dev.json to the deploy script, oraz deployment group create \
--resource-group "<rg>" \
--template-file main.bicep \
--parameters computeTier=M10 storageSizeGb=32 haTargetMode=Disabled
The currently active subscription from az account show may not be the one the user wants. Always list and confirm — never silently use the active one.
# Show all subscriptions the signed-in user can access
az account list --query "[].{Name:name, SubscriptionId:id, State:state, IsDefault:isDefault}" \
--output table
Present the list to the user and ask them to pick one (by name or ID). Then set it active so subsequent commands are scoped to it:
az account set --subscription "<subscription-id-or-name>"
az account show --query "{name:name, id:id}" -o table # confirm
Record the chosen subscription ID as $SUBSCRIPTION_ID and pass --subscription "$SUBSCRIPTION_ID" to every subsequent az command in this flow — this guarantees RG / region lookups stay scoped to the user's choice even if the active context drifts.
If the user has only one subscription, still confirm out loud ("I'll deploy into <name> — OK?") rather than silently proceeding.
List the resource groups scoped to the chosen subscription (do not omit --subscription — it prevents showing RGs from a different context):
az group list \
--subscription "$SUBSCRIPTION_ID" \
--query "[].{Name:name, Location:location}" \
--output table
Present the list to the user and ask them to pick one of:
(a) Reuse an existing RG — take its location from the table above and use that as the cluster's region by default. Skip Step 3 (the region is already fixed by the RG). Record it as $LOCATION.
(b) Create a new RG — ask the user for the new RG name, then continue to Step 3 to pick a region before creating it.
Do not proceed to Step 3 or Step 4 until the user has explicitly picked (a) or (b).
Reached only when the user chose 2(b). List the regions that support Microsoft.DocumentDB/mongoClusters so the user can pick one that is both regionally appropriate and supported:
az provider show \
--subscription "$SUBSCRIPTION_ID" \
--namespace Microsoft.DocumentDB \
--query "resourceTypes[?resourceType=='mongoClusters'].locations[]" \
--output tsv
Present the list and ask the user to pick one. Record it as $LOCATION. Then create the RG in the chosen subscription + region:
az group create \
--subscription "$SUBSCRIPTION_ID" \
--name "<new-rg-name>" \
--location "$LOCATION"
Confirm creation succeeded before moving on:
az group show --subscription "$SUBSCRIPTION_ID" --name "<new-rg-name>" --query "{name:name, location:location, state:properties.provisioningState}" -o table
Now that subscription, RG, and location are fixed, ask for cluster-specific values:
| Input | Example | Notes |
|---|---|---|
| Cluster name | docdb-prod-001 | 8–40 chars, lowercase letters/digits/hyphens; globally unique in Azure |
| Admin username | clusteradmin | Avoid reserved names like admin, root |
| Admin password | — | 8–128 chars; store in Key Vault — never commit |
| Compute tier | M30 (prod default) / M10–M20 (dev) | Full list: M10, M20, M30, M40, M50, M60, M80, M200 |
| Storage per shard (GiB) | 128 (prod default) / 32 (dev) | |
| Shard count | 1 (sufficient up to TB scale) | |
| High availability | ZoneRedundantPreferred (prod default) / SameZone / Disabled (dev) | Non-Disabled values require M30+ |
| MongoDB server version | 8.0 | |
| Public network access | Default Enabled with firewall rules | Or disable and attach Private Endpoint (see documentdb-security) |
| Authentication modes | NativeAuth + MicrosoftEntraID | Turns on Microsoft Entra sign-in alongside the admin user. Bicep: authConfig: { allowedModes: [...] }; CLI: --auth-allowed-modes. See documentdb-security for adding Entra users. |
If the user didn't answer Step 0.5, ask again — without that answer you can't pick the right tier/HA defaults.
Choose this path before Step 0 in deploy mode. In author-only mode, use the references to generate files and stop; do not execute Steps 6–10.
| Path | Use when | Section |
|---|---|---|
| Bicep (recommended) | Repeatable infra-as-code, PR-reviewed, committed to repo | Step 6a |
| Azure CLI one-shot | Prototype, local dev, quick validation | Step 6b |
| Terraform | Existing Terraform estate | Step 6c |
| Portal | First-time users who want to see the options in the UI. Not repeatable or scriptable; for automation, use one of the paths above. | Azure portal quickstart |
For Bicep, load references/bicep-cluster-template.md — it contains the canonical parameterized template and an optional private-endpoint variant.
Generate main.bicep using the template in references/bicep-cluster-template.md, then:
# 1. Sign in + select subscription
az login
az account set --subscription "<subscription-name-or-id>"
# 2. Create the resource group
az group create \
--name "<resource-group-name>" \
--location "<location>"
# 3. Deploy — you'll be prompted for adminUsername / adminPassword
az deployment group create \
--resource-group "<resource-group-name>" \
--template-file main.bicep
# Non-interactive: use a parameters file (do NOT commit passwords)
az deployment group create \
--resource-group "<resource-group-name>" \
--template-file main.bicep \
--parameters @main.parameters.json
Secret handling. Never hardcode adminPassword in main.parameters.json or a repo. Options:
{
"adminPassword": {
"reference": {
"keyVault": { "id": "/subscriptions/.../vaults/kv-documentdb" },
"secretName": "docdb-admin-password"
}
}
}
--parameters adminPassword="$(az keyvault secret show ... --query value -o tsv)".For quick iteration without a Bicep file, use the documentdb CLI extension:
az login
az account set --subscription "<subscription-name-or-id>"
# Only after explicit approval to install or upgrade the extension:
az extension add --name documentdb --upgrade
az group create --name rg-docdb-dev --location eastus2
# Set DOCDB_ADMIN_PASSWORD first, from Key Vault or your shell's secret store
az documentdb mongocluster create \
--resource-group rg-docdb-dev \
--name docdb-dev-001 \
--location eastus2 \
--admin-user clusteradmin \
--admin-password "$DOCDB_ADMIN_PASSWORD" \
--server-version "8.0" \
--tier "M10" \
--storage-size 32 \
--shard-count 1 \
--high-availability "Disabled" \
--auth-allowed-modes "NativeAuth" "MicrosoftEntraID" \
--public-network-access "Enabled"
# "Allow Azure services" shortcut uses 0.0.0.0 for both start and end
az documentdb mongocluster firewall-rule create \
--resource-group rg-docdb-dev \
--cluster-name docdb-dev-001 \
--name AllowAllAzureServices \
--start-ip-address 0.0.0.0 \
--end-ip-address 0.0.0.0
The documentdb extension's commands are currently marked preview. If you can't install CLI extensions, the generic Resource Manager commands do the same with only the core CLI:
az resource create \
--resource-group rg-docdb-dev \
--name docdb-dev-001 \
--resource-type "Microsoft.DocumentDB/mongoClusters" \
--api-version 2026-06-01 \
--location eastus2 \
--properties '{
"administrator": { "userName": "clusteradmin", "password": "REPLACE_WITH_STRONG_PASSWORD" },
"serverVersion": "8.0",
"sharding": { "shardCount": 1 },
"storage": { "sizeGb": 32 },
"highAvailability": { "targetMode": "Disabled" },
"compute": { "tier": "M10" }
}'
# Add a firewall rule — "Allow Azure services" shortcut uses 0.0.0.0 for both start and end
az resource create \
--resource-group rg-docdb-dev \
--name "docdb-dev-001/AllowAllAzureServices" \
--resource-type "Microsoft.DocumentDB/mongoClusters/firewallRules" \
--api-version 2026-06-01 \
--properties '{ "startIpAddress": "0.0.0.0", "endIpAddress": "0.0.0.0" }'
Never paste a real password on the command line in shared terminals — read it from an env var or Key Vault.
Prefer this when the user already uses Terraform. The AzureRM provider 4.x exposes azurerm_mongo_cluster, which targets Microsoft.DocumentDB/mongoClusters API 2025-09-01.
Load references/terraform-cluster-template.md for the canonical main.tf (with variables, validation, sample terraform.tfvars, and the firewall-rule pattern via the AzAPI provider). Then:
export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
export TF_VAR_admin_password=$(az keyvault secret show \
--vault-name <kv-name> --name docdb-admin-password --query value -o tsv)
# Deployment only; initialization and provider upgrades need approval too.
terraform init -upgrade
terraform plan -out main.tfplan
terraform apply main.tfplan
The provider's high_availability_mode accepts only Disabled and ZoneRedundantPreferred (the API also accepts SameZone, but that mode is not exposed through azurerm_mongo_cluster 4.x — use the Bicep template if you need it). Full Microsoft quickstart: https://learn.microsoft.com/azure/documentdb/quickstart-terraform.
az resource list \
--resource-group "<resource-group-name>" \
--namespace Microsoft.DocumentDB \
--resource-type mongoClusters \
--query "[].name" \
--output json
Expect one entry matching your cluster name.
Either way, copy the string the service gives you rather than assembling it by hand.
In the portal: open the cluster, then Connection strings.
From the CLI:
az documentdb mongocluster list-connection-strings \
--cluster-name "<cluster-name>" \
--resource-group "<resource-group-name>"
Without the documentdb extension:
az resource invoke-action \
--action listConnectionStrings \
--ids "$(az resource show -g "<resource-group-name>" -n "<cluster-name>" \
--resource-type Microsoft.DocumentDB/mongoClusters --query id -o tsv)" \
--api-version 2026-06-01
Both need Microsoft.DocumentDB/mongoClusters/listConnectionStrings/action, which the Contributor role includes.
The string contains a <password> placeholder. Fill it in at run time from an environment variable or Key Vault, and don't save the completed string in a file or commit it.
Form of the connection string:
mongodb+srv://<user>:<password>@<cluster>.global.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000
See documentdb-connection for driver-specific tuning.
Pick one posture and help the user apply it:
Public + firewall (dev only). Add the developer's IP:
MY_IP=$(curl -s https://api.ipify.org)
az documentdb mongocluster firewall-rule create \
--resource-group rg-docdb-dev \
--cluster-name docdb-dev-001 \
--name "dev-$(whoami)" \
--start-ip-address "$MY_IP" \
--end-ip-address "$MY_IP"
In the portal, the cluster's Networking page has + Add current client IP address, which does the same.
The 0.0.0.0–0.0.0.0 rule is the documented shortcut for "Allow Azure services and resources within Azure" — use for serverless workloads. Never leave 0.0.0.0–255.255.255.255 in place outside a short connection test.
Private Endpoint (prod). See documentdb-security — public access should be disabled and a Private DNS zone added.
Entra RBAC / CMK / diagnostic settings. See documentdb-security and documentdb-monitoring.
az group delete --name "<resource-group-name>" --yes --no-wait
Confirm with the user before running — this removes everything in the resource group, not just the cluster.
Microsoft.DocumentDB/mongoClusters resource referencereferences/bicep-cluster-template.md, references/terraform-cluster-template.mdexamples/azure-deployment/documentdb-local-deployment — Docker / Compose for running DocumentDB locallydocumentdb-connection — connection-string tuning after the cluster existsdocumentdb-security — Private Endpoint, Entra RBAC, CMKdocumentdb-high-availability — HA, cross-region replica, SLA tiersdocumentdb-monitoring — diagnostic settings, slow-query logsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
azure-documentdb, mongodb, infrastructure-as-code, bicep, terraform, azure-cli
17 skills in this plugin
/documentdb-connectionOptimize MongoDB client connection configuration (pools, timeouts, patterns) for Azure DocumentDB. Use this skill when working on functions that instantiate or configure a MongoDB client (e.g., calling `connect()`), configuring connection pools, troubleshooting connection errors (ECONNREFUSED, timeouts, pool exhaustion), optimizing connection-related performance issues. Includes scenarios like building serverless functions, creating API endpoints, optimizing high-traffic applications, or debugging connection failures./documentdb-data-modelingData modeling patterns for Azure DocumentDB (with MongoDB compatibility) — embed vs reference, 16 MB document limit, denormalization for read-heavy workloads, schema versioning, monetary amounts, and UTC BSON dates. Use when designing new schemas, reviewing existing data models, migrating from SQL, deciding between embedding and referencing, modeling one-to-one / one-to-many / many-to-many relationships, or troubleshooting document-size and query-performance problems that stem from the data model./documentdb-driverMongoDB driver and SDK best practices for Azure DocumentDB (with MongoDB compatibility) — singleton MongoClient, connection reuse, connection-pool fundamentals. Use when writing code that instantiates a MongoDB client, reviewing driver initialization, or diagnosing connection-related bugs. For full connection-pool tuning (serverless vs OLTP vs OLAP, timeouts, retries), see the documentdb-connection skill.npx claudepluginhub azure/documentdb-agent-kit --plugin documentdbOther plugins' skills for the same job