Deployment of CosmosDB with shared autoscaling throughput fails

Viewed 529

Trying to deploy ARM Template for a Database Account, SQL Database with two Collections where autoscale throughput setting are set at the database level (shared for collections).

I created this setup in Azure UI and then exported the template. When importing the template from Powershell using New-AzResourceGroupDeployment it fails with message

Status Message: Entity with the specified id does not exist in the system.
ActivityId: <redacted>, Microsoft.Azure.Documents.Common/2.11.0 (Code:NotFound)

This is ridiculous because I exported the template and did not modify it and then imported. Isn't Azure recognizing it's own format? I think the problem has to do with this fragment of template:

{
    "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings",
    "apiVersion": "2020-04-01",
    "name": "[concat(parameters('databaseAccounts_an_test_name'), '/', parameters('databaseAccounts_an_test_name'), '-db-2/default')]",
    "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccounts_an_test_name'), concat(parameters('databaseAccounts_an_test_name'), '-db-2'))]",
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_an_test_name'))]"
    ],
    "properties": {
        "resource": {
            "throughput": 400,
            "autoscaleSettings": {
                "maxThroughput": 4000
            }
        }
    }
}

enter image description here

Any ideas?

2 Answers

Based on Mark Brown hints this is the exact solution.

{
    "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
    "name": ...
    "apiVersion": "2020-04-01"
    "dependsOn": ...
    "properties": {
      "resource": {
        "id": ...
      },
      "options": {
        "autoscaleSettings": {
          "maxThroughput": 4000
        }
      }
    }
}

Don't use the Microsoft.DocumentDB/databaseAccounts/sqlDatabases/throughputSettings part of yaml from exported template. I'm not sure why Azure exports it and then doesn't allow for import.

If you are creating a new database or container resource you need to pass the throughput in the options for the resource. You can only use the throughput resource directly when updating the throughput.

Here is an example here

Related