title: Why does setting CosmosDB throughputSettings result in "Entity with the specified id does not exist in the system"?
body: <p>While trying to deploy a CosmosDB instance with 2 collections ("MyCollection1", "MyCollection2") I keep getting the error:</p>
  
  <blockquote>
    <p>NotFound: Entity with the specified id does not exist in the system</p>
  </blockquote>
  
  <p>So I keep searching for "resourceId" in my custom ARM template (please see below) but cannot find the erorr cause.</p>
  
  <p>I don't understand, why does not the pipeline at least print the line number for me?</p>
  
  <p><a href="https://i.stack.imgur.com/KXrPd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KXrPd.png" alt="pipeline screenshot"></a></p>
  
  <pre><code>{
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
          "accountName": {
              "defaultValue": "my-cosmosdb",
              "type": "String"
          }
      },
      "variables": {
          "resourceName": "[concat(resourceGroup().name, '-', parameters('accountName'))]",
          "resourceId": "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]",
          "apiVersion": "[providers('Microsoft.DocumentDB', 'databaseAccounts').apiVersions[0]]"
      },
      "outputs": {
          "CosmosDbConnectionString": {
              "type": "string",
              "value": "[concat('AccountEndpoint=https://', variables('resourceName'), '.documents.azure.com:443/;AccountKey=', listKeys(variables('resourceId'), variables('apiVersion')).primaryMasterKey, ';')]"
          },
          "DatabaseName": {
              "type": "string",
              "value": "MyDB"
          },
          "CollectionName1": {
              "type": "string",
              "value": "MyCollection1"
          },
          "CollectionName2": {
              "type": "string",
              "value": "MyCollection2"
          }
      },
      "resources": [
          {
              "type": "Microsoft.DocumentDB/databaseAccounts",
              "apiVersion": "2020-03-01",
              "name": "[variables('resourceName')]",
              "location": "[resourceGroup().location]",
              "tags": {
                  "defaultExperience": "DocumentDB"
              },
              "kind": "GlobalDocumentDB",
              "properties": {
                  "publicNetworkAccess": "Enabled",
                  "enableAutomaticFailover": false,
                  "enableMultipleWriteLocations": false,
                  "isVirtualNetworkFilterEnabled": false,
                  "virtualNetworkRules": [],
                  "disableKeyBasedMetadataWriteAccess": false,
                  "databaseAccountOfferType": "Standard",
                  "consistencyPolicy": {
                      "defaultConsistencyLevel": "Session",
                      "maxIntervalInSeconds": 5,
                      "maxStalenessPrefix": 100
                  },
                  "locations": [
                      {
                          "locationName": "[resourceGroup().location]",
                          "provisioningState": "Succeeded",
                          "failoverPriority": 0,
                          "isZoneRedundant": false
                      }
                  ],
                  "capabilities": []
              }
          },
          {
              "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
              "apiVersion": "2020-03-01",
              "name": "[concat(variables('resourceName'), '/MyDB')]",
              "dependsOn": [
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
              ],
              "properties": {
                  "resource": {
                      "id": "MyDB"
                  },
                  "options": {}
              }
          },
          {
              "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
              "apiVersion": "2020-03-01",
              "name": "[concat(variables('resourceName'), '/MyDB/MyCollection1')]",
              "dependsOn": [
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
              ],
              "properties": {
                  "resource": {
                      "id": "MyCollection1",
                      "indexingPolicy": {
                          "indexingMode": "consistent",
                          "automatic": true,
                          "includedPaths": [
                              {
                                  "path": "/*"
                              }
                          ],
                          "excludedPaths": [
                              {
                                  "path": "/\"_etag\"/?"
                              }
                          ]
                      },
                      "partitionKey": {
                          "paths": [
                              "/partitionKey"
                          ],
                          "kind": "Hash"
                      },
                      "uniqueKeyPolicy": {
                          "uniqueKeys": []
                      },
                      "conflictResolutionPolicy": {
                          "mode": "LastWriterWins",
                          "conflictResolutionPath": "/_ts"
                      }
                  },
                  "options": {}
              }
          },
          {
              "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
              "apiVersion": "2020-03-01",
              "name": "[concat(variables('resourceName'), '/MyDB/MyCollection2')]",
              "dependsOn": [
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
              ],
              "properties": {
                  "resource": {
                      "id": "MyCollection2",
                      "indexingPolicy": {
                          "indexingMode": "consistent",
                          "automatic": true,
                          "includedPaths": [
                              {
                                  "path": "/*"
                              }
                          ],
                          "excludedPaths": [
                              {
                                  "path": "/\"_etag\"/?"
                              }
                          ]
                      },
                      "partitionKey": {
                          "paths": [
                              "/partitionKey"
                          ],
                          "kind": "Hash"
                      },
                      "uniqueKeyPolicy": {
                          "uniqueKeys": []
                      },
                      "conflictResolutionPolicy": {
                          "mode": "LastWriterWins",
                          "conflictResolutionPath": "/_ts"
                      }
                  },
                  "options": {}
              }
          },
          {
              "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings",
              "apiVersion": "2020-03-01",
              "name": "[concat(variables('resourceName'), '/MyDB/default')]",
              "dependsOn": [
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
                  "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
              ],
              "properties": {
                  "resource": {
                      "throughput": 400
                  }
              }
          }
      ]
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have removed the part creating collections and the error is still there.</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>The following part seemingly causes the error, but why?</p>
  
  <pre><code>{
      "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings",
      "apiVersion": "2020-03-01",
      "name": "[concat(variables('resourceName'), '/MyDB/default')]",
      "dependsOn": [
          "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]",
          "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('resourceName'))]"
      ],
      "properties": {
          "resource": {
              "throughput": 400
          }
      }
  }
  </code></pre>
  
  <p>What is wrong with the <strong>dependsOn</strong> entry <code>"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('resourceName'), 'MyDB')]</code>?</p>
  
  <p><strong>UPDATE 3:</strong></p>
  
  <p>Trying to deploy the complete ARM template listed above manually results in:</p>
  
  <p><a href="https://i.stack.imgur.com/u3wtW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u3wtW.png" alt="screenshot throughput error"></a></p>
  
  <p><a href="https://i.stack.imgur.com/sLVZW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sLVZW.png" alt="screenshot error"></a></p>