Azure / Azure/azure-quickstart-templates
Difficulty enabling/disabling analytical storage in CosmosDB using template parameters
- Dominant language
- Bicep
- Stars
- 14.9k
- Forks
- 16.2k
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 6
Description
### Issue Details
My team is working on a gradual rollout of CosmosDB analytical storage. Since the rollout is gradual, we need to be able to enable/disable analytical storage for particular tables using an arm template parameter.
We tried the following syntax, but received the following error:
```
{
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
"name": "[concat(variables('cosmosDBAccountName'), '/', parameters('databaseName'))]",
"apiVersion": "2020-04-01",
"dependsOn": [
"[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDBAccountName'))]"
],
"properties": {
"resource": {
"id": "[parameters('databaseName')]"
},
"options": {}
}
},
...
{
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
"name": "[concat(variables('cosmosDBAccountName'), '/', parameters('databaseName'), '/', '[redacted]')]",
"apiVersion": "2020-04-01",
"dependsOn": [
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('cosmosDBAccountName'), parameters('databaseName'))]"
],
"properties": {
"resource": {
...
"analyticalStorageTtl": "[if(parameters('enableNewApplianceAnalyticalStorage'), -1, 0)]"
},
"options": "[variables('throughputPolicy')[parameters('throughputPolicy')]]"
}
}
```
```
{"code":"BadRequest","message":"Message: {\"Errors\":[\"The input content is invalid - 'analyticalStorageTtl' is not a valid property in the current payload.\"]}\r
ActivityId: 715a13bc-e1aa-4037-bfd9-66973d6a30f8, Request URI: /apps/f71e46ae-dbec-4fc6-8889-678d8885e8c6/services/3c6977b4-e420-4d05-ae08-450ca45e4945/partitions/888c1aa7-4be5-41fb-afd0-8c3910113bca/replicas/133081710061267281p, RequestStats: \r
RequestStartTime: 2023-05-12T19:51:53.0866020Z, RequestEndTime: 2023-05-12T19:51:53.0866020Z, Number of regions attempted:1
```
We also tried using this link - https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.network/azurefirewall-create-with-zones/azuredeploy.json#L73:
```
{
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
"name": "[concat(variables('cosmosDBAccountName'), '/', parameters('databaseName'))]",
"apiVersion": "2020-04-01",
"dependsOn": [
"[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDBAccountName'))]"
],
"properties": {
"resource": {
"id": "[parameters('databaseName')]"
},
"options": {}
}
},
...
{
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
"name": "[concat(variables('cosmosDBAccountName'), '/', parameters('databaseName'), '/', '[redacted]')]",
"apiVersion": "2020-04-01",
"dependsOn": [
"[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', variables('cosmosDBAccountName'), parameters('databaseName'))]"
],
"properties": {
"resource": {
...
"analyticalStorageTtl": "[if(parameters('enableNewApplianceAnalyticalStorage'), -1, json('null'))]"
},
"options": "[variables('throughputPolicy')[parameters('throughputPolicy')]]"
}
}
```
and received this error:
```
{"code":"BadRequest","message":"Message: {\"Errors\":[\"One of the specified inputs is invalid\"]}\r
ActivityId: 66e8bc3f-12d0-457d-9254-545f8b5b83d7, Request URI: /apps/255bae47-a9ff-42a3-a5b5-f484fe198df7/services/87df5ec9-1f1c-41ef-a2a6-6d4e09b595be/partitions/8e8872a8-b363-4934-8b74-7c31f667cb27/replicas/133286868070753680p, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.14.0"}
```
Is there a way to conditionally drop fields using something similar to if statements?
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue contains inline ARM JSON for Microsoft.DocumentDB SQL databases and containers, including the analyticalStorageTtl expression. Start by checking the ARM template schema and current Azure Cosmos DB template guidance for conditional properties. Done means establishing whether conditional omission is supported and documenting a valid template approach or the service limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, databases, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100