azure-rest-api-specs icon indicating copy to clipboard operation
azure-rest-api-specs copied to clipboard

[BUG] Microsoft.DocumentDB - lack of property autoscaleSettings in GET of mongodbDatabases

Open dj-r1 opened this issue 1 year ago • 6 comments

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

dj-r1 avatar Oct 17 '24 15:10 dj-r1

@carjackson-msft Please help take a look, thanks.

v-jiaodi avatar Oct 18 '24 08:10 v-jiaodi

Discussed with @pjohari-ms - re-assigning to Mark Brown @markjbrown to help triage issue.

ghost avatar Oct 28 '24 23:10 ghost

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.

markjbrown avatar Oct 29 '24 11:10 markjbrown

Hi @markjbrown, to clarify, the issue is opened by @dj-r1

ghost avatar Oct 29 '24 15:10 ghost

Thanks @carjackson-msft! @dj-r1 please see my comment above.

markjbrown avatar Oct 29 '24 15:10 markjbrown

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

  1. name is truly xxGG - Is it a bug, if in the definition a had to use default?
  2. maxThroughput is returned together with throughput. To the second, examples do not show how is the logic when maxThroughput is used. I'm asking because in WhatIf operation again complain about actual throughput, 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?

dj-r1 avatar Oct 30 '24 17:10 dj-r1

  1. I was little wrong with referencing using Get Mongo DB Collection Throughput, I meant Get Mongo DB Database Throughput. Regarding maxThroughput and throughput returned 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 returned throughput should be captured by WhatIf project as a noise, but expected property in REST API. Thank you @markjbrown for response.

  2. Regarding returned "name": "xxGG" where the name is default - I think it's a strange response, not consistent with API specification (Sample response). Is there any plan to correct it?

dj-r1 avatar Nov 26 '24 15:11 dj-r1