Azure/azure-rest-api-specs

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

dj-r1 opened this issue · 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

@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

  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?