jkhanbanner
jkhanbanner

Reputation: 59

Enabling disableLocalAuth in cosmos Db using ARM Template

I am deploying Azure Cosmos DB using ARM templates. I have two parameter file one for Dev environment and one PROD, also an arm template containing configuration for Cosmos DB. In either to secure my DB, I would have to set true to parameter for disableLocalAuth as shown below

"resources": [
    {
        "type": " Microsoft.DocumentDB/databaseAccounts",
        "properties": {
            "disableLocalAuth": true,
            // ...
        },
        // ...
    },
    // ...
 ]

I want to add additional parameter in my parameter file, and in Dev Parameter file, set the disableLocalAuth to false and for PROD parameter file set the disableLocalAuth to true

I need example where how I can set additional parameter to reflect the change in different environment.

Thank you

Upvotes: 0

Views: 1022

Answers (1)

Mark Brown
Mark Brown

Reputation: 8763

Here's a template with a parameter for this value.

{
   "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
   "contentVersion": "1.0.0.0",
   "parameters": {
      "accountName": {
         "type": "string",
         "defaultValue": "[uniqueString(resourceGroup().id)]"
      },
 
      "disableLocalAuth": {
         "type": "bool",
         "defaultValue": false
      }
   },
   "resources": [
      {
         "type": "Microsoft.DocumentDB/databaseAccounts",
         "name": "[parameters('accountName')]",
         "apiVersion": "2021-10-15",
         "location": "West US",
         "kind": "GlobalDocumentDB",
         "properties": {
            "locations": [{ "locationName": "West US", "failoverPriority": 0 }],
            "databaseAccountOfferType": "Standard",
            "disableLocalAuth": "[parameters('disableLocalAuth')]" 
         }
      }
   ]
}

Upvotes: 1

Related Questions