pulumi / pulumi-azure

A Microsoft Azure Pulumi resource package, providing multi-language access to Azure
Apache License 2.0
132 stars 50 forks source link

azure - python - CosmosDb MongoCollection - Error reading or replacing offers from CosmosDB serverless database #786

Closed Ratomir closed 3 years ago

Ratomir commented 3 years ago

I am getting an error with azure cosmosDB MongoCollection in Serverless Account mode. Here is the full message: updating urn:pulumi:dev::blog-main::azure:cosmosdb/mongoCollection:MongoCollection::dbCollection-tagindex: Error reading Throughput on Cosmos Mongo Collection "tagindex" (Account: "cosmos-dw-blog-dev", Database: "blog-db"): documentdb.MongoDBResourcesClient#GetMongoDBCollectionThroughput: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Message: {\"code\":\"BadRequest\",\"message\":\"Reading or replacing offers is not supported for serverless accounts.\\r\\nActivityId: 9eda1def-0cb5-42f2-ab5b-71b2ed3a4b43, Microsoft.Azure.Documents.Common/2.11.0\"}, Request URI: /offers, RequestStats: , SDK: Microsoft.Azure.Documents.Common/2.11.0"

Expected Behavior

The Pulumi doesn't need to read offers of the Cosmos DB account at the time of collection update with Serverless mode.

Current Behavior

The Pulumi tries to find the offer of the Cosmos DB and update it.

Steps to Reproduce

  1. Create a new project with azure and python
  2. Create a Cosmos DB account with the Serverless mode
    azure.cosmosdb.Account("db",
                                              name="cosmos-" + name + "-" + config.project_name + "-" + config.env,
                                              location=resource_group.location,
                                              resource_group_name=resource_group.name,
                                              offer_type="Standard",
                                              kind="MongoDB",
                                              enable_free_tier=True,
                                              capabilities=[
                                                  cosmosdb.AccountCapabilityArgs(name="EnableServerless"),
                                                  cosmosdb.AccountCapabilityArgs(name="EnableMongo")],
                                              enable_automatic_failover=False,
                                              consistency_policy={
                                                  "consistencyLevel": "Session"
                                              },
                                              geo_locations=[
                                                  {
                                                      "location": resource_group.location,
                                                      "failoverPriority": 0,
                                                  },
                                              ])
  3. Create a Cosmos DB Mongo database
    azure.cosmosdb.MongoDatabase(database_name,
                                                     name=database_name,
                                                     resource_group_name=resource_group.name,
                                                     account_name=cosmos_account)
  4. Create a Cosmos DB Mongo collection
    azure.cosmosdb.MongoCollection("dbCollection-" + collection_name,
                                                    name=collection_name,
                                                    resource_group_name=resource_group.name,
                                                    account_name=cosmos_account,
                                                    database_name=database_name,
                                                    indices=[
                                                        cosmosdb.MongoCollectionIndexArgs(keys=['_id'], unique=True)
                                                    ],
                                                    shard_key="id")

Context (Environment)

This issue may be similar to this one: https://github.com/terraform-providers/terraform-provider-azurerm/issues/8661

Thank you :)

mikhailshilkov commented 3 years ago

Which version of pulumi-azure are you on? The issue you linked was supposed to be fixed in 3.19.0 (v2.25.0 of the TF provider).

mikhailshilkov commented 3 years ago

I'll close this issue for now as it should be fixed. Feel free to reopen (or report back to Terraform) if you still have it with the latest version.