Configure your Azure Cosmos DB for MongoDB account capabilities

APPLIES TO: MongoDB

Capabilities are features that can be added or removed to your API for MongoDB account. Many of these features affect account behavior so it's important to be fully aware of the effect a capability will have before enabling or disabling it. Several capabilities are set on API for MongoDB accounts by default, and can't be changed or removed. One example is the EnableMongo capability. This article will demonstrate how to enable and disable a capability.

Prerequisites

Available capabilities

Capability Description Removable
DisableRateLimitingResponses Allows Mongo API to retry rate-limiting requests on the server-side until max-request-timeout Yes
EnableMongoRoleBasedAccessControl Enable support for creating Users/Roles for native MongoDB role-based access control No
EnableMongoRetryableWrites Enables support for retryable writes on the account Yes
EnableMongo16MBDocumentSupport Enables support for inserting documents upto 16 MB in size No
EnableUniqueCompoundNestedDocs Enables support for compound and unique indexes on nested fields, as long as the nested field is not an array. No

Enable a capability

  1. Retrieve your existing account capabilities by using az cosmosdb show:

    az cosmosdb show \
        --resource-group <azure_resource_group> \
        --name <azure_cosmos_db_account_name>
    

    You should see a capability section similar to this output:

    "capabilities": [
      {
        "name": "EnableMongo"
      }
    ]
    

    Review the default capability. In this example, we have just EnableMongo.

  2. Set the new capability on your database account. The list of capabilities should include the list of previously enabled capabilities, since only the explicitly named capabilities will be set on your account. For example, if you want to add the capability DisableRateLimitingResponses, you would use the az cosmosdb update command with the --capabilities parameter:

    az cosmosdb update \
        --resource-group <azure_resource_group> \
        --name <azure_cosmos_db_account_name> \
        --capabilities EnableMongo, DisableRateLimitingResponses
    

    Tip

    If you're using PowerShell and receive an error using the command above, try using a PowerShell array instead to list the capabilities:

    az cosmosdb update \
        --resource-group <azure_resource_group> \
        --name <azure_cosmos_db_account_name> \
        --capabilities @("EnableMongo","DisableRateLimitingResponses")
    

Disable a capability

  1. Retrieve your existing account capabilities by using az cosmosdb show:

    az cosmosdb show \
        --resource-group <azure_resource_group> \
        --name <azure_cosmos_db_account_name>
    

    You should see a capability section similar to this output:

    "capabilities": [
      {
        "name": "EnableMongo"
      },
      {
        "name": "DisableRateLimitingResponses"
      }
    ]
    

    Observe each of these capabilities. In this example, we have EnableMongo and DisableRateLimitingResponses.

  2. Remove the capability from your database account. The list of capabilities should include the list of previously enabled capabilities you want to keep, since only the explicitly named capabilities will be set on your account. For example, if you want to remove the capability DisableRateLimitingResponses, you would use the az cosmosdb update command:

    az cosmosdb update \
        --resource-group <azure_resource_group> \
        --name <azure_cosmos_db_account_name> \
        --capabilities EnableMongo
    

    Tip

    If you're using PowerShell and receive an error using the command above, try using a PowerShell array instead to list the capabilities:

    az cosmosdb update \
        --resource-group <azure_resource_group> \
        --name <azure_cosmos_db_account_name> \
        --capabilities @("EnableMongo")
    

Next steps