[BUG] Microsoft.DocumentDB - lack of property autoscaleSettings in GET of mongodbDatabases
API Spec link
https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-08-15/cosmos-db.json
API Spec version
2024-08-15, 2024-02-15-preview
Describe the bug
In a ARM template (Bicep) of Microsoft.DocumentDB/databaseAccounts/mongodbDatabases
{
"type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases",
"apiVersion": "2024-05-15",
"name": "string",
"location": "string",
...
"properties": {
"options": {
"autoscaleSettings": {
"maxThroughput": "int"
},
"throughput": "int"
},
"resource": {
"createMode": "string",
"id": "string",
...
}
}
}
points out that CreateUpdateOptionsOrMongoDBDatabaseGetPropertiesOptions is a part of the template, so in GET request it may be in a response, but in az rest and az cosmosdb mongodb database show response is not.
Example CosmosDBMongoDBDatabaseGet.json has a response with main properties of the resource without CreateUpdateOptionsOrMongoDBDatabaseGetPropertiesOptions. In Cosmos DB REST API - Get a Database it's the same.
In my case I struggle with What-If operation response showing me lack of autoscaleSettings.maxThroughput in Azure, where it's set and valid. I assume arm-template-whatif receives information from Azure REST API and compares it with my generated ARM template (Bicep).
Should CreateUpdateOptionsOrMongoDBDatabaseGetPropertiesOptions be a part of GET mongoDB database? Or could you guide me to the root cause?
I know that there is a separate Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/mongodbCollections/throughputSettings extension resource with adequate example CosmosDBMongoDBCollectionThroughputGet.json. In my case I tried use it, but without good result.
Expected behavior
{
"id": "/subscriptions/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmos-account/mongodbDatabases/my-mongo-db",
"name": "my-mongo-db",
"properties": {
"options": {
"autoscaleSettings": {
"maxThroughput": 1000
}
},
"resource": {
"id": "my-mongo-db"
}
},
"type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases"
}
Actual behavior
{
"id": "/subscriptions/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmos-account/mongodbDatabases/my-mongo-db",
"name": "my-mongo-db",
"properties": {
"resource": {
"id": "my-mongo-db"
}
},
"type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases"
}
Reproduction Steps
az cosmosdb mongodb database show --resource-group 'my-rg' --name 'my-mongo-db' --account-name 'my-cosmos-account'
||
az rest --method get --header "Accept=application/json" --url 'https://management.azure.com/subscriptions/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmos-account/mongodbDatabases/my-mongo-db?api-version=2024-08-15'
||
GET https://management.azure.com/subscriptions/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmos-account/mongodbDatabases/my-mongo-db?api-version=2024-08-15
Environment
No response
@carjackson-msft Please help take a look, thanks.
Discussed with @pjohari-ms - re-assigning to Mark Brown @markjbrown to help triage issue.
Hi @carjackson-msft. I'm confused on how you are trying to get throughput for a mongo collection. The Get example you show is not for the throughput resource but for the parent collection. To get throughput use this.
https://learn.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/mongo-db-resources/get-mongo-db-collection-throughput?view=rest-cosmos-db-resource-provider-2024-08-15&tabs=HTTP
hope that helps.
Hi @markjbrown, to clarify, the issue is opened by @dj-r1
Thanks @carjackson-msft! @dj-r1 please see my comment above.
Thank you @markjbrown. Now I changed it to ARM Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/throughputSettings using Get Mongo DB Collection Throughput. But in Azure I had set mongoDb with maxThroughput. The response for throughputSettings results in
{
"value": [
{
"id": "/subscriptions/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb/resourceGroups/my-rg/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmosdb/mongodbDatabases/my-mongo-cosmosdb/throughputSettings/default",
"name": "xxGG",
"properties": {
"resource": {
"autoscaleSettings": {
"maxThroughput": 1000
},
"instantMaximumThroughput": "10000",
"minimumThroughput": "1000",
"softAllowedMaximumThroughput": "1000000",
"throughput": 100
}
},
"type": "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/throughputSettings"
}
]
}
So where
-
nameis trulyxxGG- Is it a bug, if in the definition a had to usedefault? -
maxThroughputis returned together withthroughput. To the second, examples do not show how is the logic whenmaxThroughputis used. I'm asking because in WhatIf operation again complain about actualthroughput, where they can't be defined together, as Azure REST API Description states:
| throughput | integer | Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both.
So having throughput with maxThroughput in the response is it a bug or the designed response?
-
I was little wrong with referencing using Get Mongo DB Collection Throughput, I meant Get Mongo DB Database Throughput. Regarding
maxThroughputandthroughputreturned together, I understand that's normal approach. With IaC Bicep provisioning I had use breakneck way with two templates. First provisioning MongoDB with autoscaleSettings, and then with re-deployment with pre-check if autoscaleSettings are applied already, and then (with excluding autoscaleSettings in main MongoDb template) to use additional template throughputSettings. I understand now that returnedthroughputshould be captured by WhatIf project as a noise, but expected property in REST API. Thank you @markjbrown for response. -
Regarding returned
"name": "xxGG"where the name isdefault- I think it's a strange response, not consistent with API specification (Sample response). Is there any plan to correct it?