0

I'm looking for a way to set the initial value of throughput (request units) for a cosmosdb database or container via an ARM Template, and to use the same ARM template for subsequent deployments.

Here's a sample:

{
    "type": "Microsoft.DocumentDB/databaseAccounts",
    "apiVersion": "2016-03-31",
    "name": "DBACCOUNTNAME",
    "location": "Canada Central",
    "kind": "GlobalDocumentDB",
    "properties": {
        "consistencyPolicy": {
            "defaultConsistencyLevel": "BoundedStaleness",
            "maxStalenessPrefix": 100,
            "maxIntervalInSeconds": 5
        },
        "databaseAccountOfferType": "Standard",
        "locations": [ { "locationName": "Canada Central" } ],
        "enableAutomaticFailover": false,
        "isVirtualNetworkFilterEnabled": false
    }
},
{
    "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
    "apiVersion": "2016-03-31",
    "name": "DBACCOUNTNAME/sql/DBNAME",
    "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts/', 'DBACCOUNTNAME')]"
    ],
    "properties": {
        "resource": {
            "id": "DBNAME"
        }
    }
},
{
    "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases/containers",
    "apiVersion": "2016-03-31",
    "name": "DBACCOUNTNAME/sql/DBNAME/data",
    "dependsOn": [
    "[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', 'DBACCOUNTNAME', 'sql', 'DBNAME')]"
    ],
    "properties": {
        "resource": {
            "id": "data",
            "partitionKey": {
            "paths": [ "/id" ]
            }
        },
        "options": { "throughput": "2000" }
    }
}

As you can see at the bottom, in this case our initial throughput value is 2000. The default is 400.

This ARM template works if:

  • This is the first deployment, or
  • This is a subsequent deployment AND the throughput has not changed in the meantime.

It does NOT work if:

  • The throughput has changed (for example, we're auto-scaling it based on real-time metrics)

...

It's possible to use [reference(..)] to get a reference to the current throughput. That can be used for subsequent updates without changing throughput, but it can't be used to initially create the resource.

...

How can I have a single ARM template which I can redeploy in this case?

Josh
  • 2,958
  • 3
  • 16
  • 27
  • Can't you use Powershell to update the throughput after the deployment has happened? I mean to ask whether you have to do it by ARM templates alone? – bit Sep 04 '19 at 05:14
  • Sure, I can use powershell or other solutions. They all add complexity which "shouldn't" be required. I was seeking a options { initialThroughput : ... } type of setting. – Josh Sep 04 '19 at 13:51

1 Answers1

0

not much you can do, as ARM Templates are not meant for that, you need to store the throughput somewhere externally (or retrieve it with some sort of script) and pass it in as a parameter to the template.

this happens because cosmos RP handles these requests in a weird fashion. normally this would be possible (but it would revert your throughput to the value specified in the template).

4c74356b41
  • 69,186
  • 6
  • 100
  • 141