{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "accountName": { "type": "string", "metadata": { "description": "The name of Azure Cosmos DB SQL API account" } }, "location": { "type": "string", "metadata": { "description": "Location for the Cosmos DB account." } }, "primaryRegion": { "type": "string", "metadata": { "description": "The primary replica region for the Cosmos DB account." } }, "secondaryRegion": { "type": "string", "metadata": { "description": "The secondary replica region for the Cosmos DB account." } }, "defaultConsistencyLevel": { "type": "string", "metadata": { "description": "The default consistency level of the Cosmos DB account." } }, "automaticFailover": { "type": "bool", "metadata": { "description": "Enable automatic failover for regions. Ignored when Multi-Master is enabled" } } }, "variables": { "accountName": "[toLower(parameters('accountName'))]", "consistencyPolicy": { "Eventual": { "defaultConsistencyLevel": "Eventual" }, "ConsistentPrefix": { "defaultConsistencyLevel": "ConsistentPrefix" }, "Session": { "defaultConsistencyLevel": "Session" }, "Strong": { "defaultConsistencyLevel": "Strong" } }, "locations": [ { "locationName": "[parameters('primaryRegion')]", "failoverPriority": 0, "isZoneRedundant": false }, { "locationName": "[parameters('secondaryRegion')]", "failoverPriority": 1, "isZoneRedundant": false } ] }, "resources": [ { "type": "Microsoft.DocumentDB/databaseAccounts", "name": "[variables('accountName')]", "apiVersion": "2020-03-01", "location": "[parameters('location')]", "tags": { "Owner": "[resourceGroup().tags.Owner]", "Env": "[resourceGroup().tags.Env]", "ComponentId": "[resourceGroup().tags.ComponentId]" }, "kind": "GlobalDocumentDB", "properties": { "consistencyPolicy": "[variables('consistencyPolicy')[parameters('defaultConsistencyLevel')]]", "locations": "[variables('locations')]", "databaseAccountOfferType": "Standard", "enableAutomaticFailover": "[parameters('automaticFailover')]" } } ], "outputs": { "primaryConnectionString": { "type": "string", "value": "[concat(listConnectionStrings(resourceId(resourcegroup().name, 'Microsoft.DocumentDB/databaseAccounts', variables('accountName')), providers('Microsoft.DocumentDB', 'databaseAccounts').apiVersions[0]).connectionStrings[0].connectionString)]" } } }