title: Azure ARM templates with Storage and Cosmos Db connection strings
body: <p>I hope someone knows how to do this.
  I have setup an ARM template which creates my resources when I do CI/CD which is great.
  I have even managed to set up a connection string:</p>
  
  <pre><code>"ConnectionStrings:ConnectionString": "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', variables('name'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('sqlMasterName'), ';User Id=', variables('sqlServerUser'), '@', reference(concat('Microsoft.Sql/servers/', variables('name'))).fullyQualifiedDomainName, ';Password=', variables('sqlServerPassword'), ';')]",
  </code></pre>
  
  <p>the variable <strong>sqlServerPassword</strong> is randomly generated by this:</p>
  
  <pre><code>"sqlServerPassword": "[concat('P', uniqueString(resourceGroup().id, '224F5A8B-51DB-46A3-A7C8-59B0DD584A41'), 'x', '!')]",
  </code></pre>
  
  <p>With that in mind does anyone know how I can do the same for the storage account and for an azure cosmos db?
  It doesn't seem to be the same.</p>
  
  <p>My template for creating my storage account looks like this:</p>
  
  <pre><code>{
    "apiVersion": "2018-11-01",
    "type": "Microsoft.Storage/storageAccounts",
    "name": "[variables('name')]",
    "location": "[variables('location')]",
    "tags": {
      "displayName": "SXP storage"
    },
    "kind": "Storage",
    "sku": {
      "name": "Standard_LRS"
    }
  },
  </code></pre>
  
  <p>Which doesn't mention a password, etc.
  Also, for my CosmosDb I have the same issue:</p>
  
  <pre><code>{
    "name": "[variables('name')]",
    "type": "Microsoft.DocumentDB/databaseAccounts",
    "apiVersion": "2015-04-08",
    "location": "[variables('location')]",
    "tags": {
      "displayName": "Cosmos DB Account"
    },
    "properties": {
      "locations": "[variables('locations')]",
      "databaseAccountOfferType": "Standard"
    }
  },
  {
    "name": "[concat(variables('name'), '/sql/', variables('cosmosMasterName'))]",
    "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
    "apiVersion": "2016-03-31",
    "dependsOn": [
      "[resourceId('Microsoft.DocumentDB/databaseAccounts/', variables('name'))]"
    ],
    "properties": {
      "resource": {
        "id": "[variables('cosmosMasterName')]"
      },
      "options": { "throughput": "[variables('cosmosMasterThroughPut')]" }
    }
  },
  {
    "name": "[concat(variables('name'), '/sql/', variables('cosmosMasterName'), '/', variables('cosmosContainerName'))]",
    "type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/containers",
    "apiVersion": "2016-03-31",
    "dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('name'), 'sql', variables('cosmosMasterName'))]" ],
    "properties": {
      "resource": {
        "id": "[variables('cosmosContainerName')]",
        "partitionKey": {
          "paths": [
            "/gtin"
          ],
          "kind": "Hash"
        },
        "indexingPolicy": {
          "indexingMode": "consistent",
          "includedPaths": [
            {
              "path": "/*"
            }
          ]
        }
      }
    }
  },
  {
    "name": "[concat(variables('name'), '/sql/', variables('cosmosDevelopName'))]",
    "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
    "apiVersion": "2016-03-31",
    "dependsOn": [
      "[resourceId('Microsoft.DocumentDB/databaseAccounts/', variables('name'))]"
    ],
    "properties": {
      "resource": {
        "id": "[variables('cosmosDevelopName')]"
      },
      "options": { "throughput": "[variables('cosmosDevelopThroughPut')]" }
    }
  },
  {
    "name": "[concat(variables('name'), '/sql/', variables('cosmosDevelopName'), '/', variables('cosmosContainerName'))]",
    "type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/containers",
    "apiVersion": "2016-03-31",
    "dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('name'), 'sql', variables('cosmosDevelopName'))]" ],
    "properties": {
      "resource": {
        "id": "[variables('cosmosContainerName')]",
        "partitionKey": {
          "paths": [
            "/gtin"
          ],
          "kind": "Hash"
        },
        "indexingPolicy": {
          "indexingMode": "consistent",
          "includedPaths": [
            {
              "path": "/*"
            }
          ]
        }
      }
    }
  }
  </code></pre>
  
  <p>If anyone can help, that would be great.</p>