question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create a mongodb collection using azure cli with an index policy

See original GitHub issue

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az cosmosdb mongodb collection create

Errors:

Unable to build a model: Cannot deserialize as [MongoIndex] an object of type <class 'dict'>, DeserializationError: Cannot deserialize as [MongoIndex] an object of type <class 'dict'>
Traceback (most recent call last):
Temp\pip-unpacked-wheel-ib_p0vwa\msrest\serialization.py, ln 571, in body
Temp\pip-unpacked-wheel-ib_p0vwa\msrest\serialization.py, ln 1261, in _deserialize
Temp\pip-unpacked-wheel-ib_p0vwa\msrest\serialization.py, ln 1261, in _deserialize
...
msrest.exceptions.SerializationError: Unable to build a model: Cannot deserialize as [MongoIndex] an object of type <class 'dict'>, DeserializationError: Cannot deserialize as [MongoIndex] an object of type <class 'dict'>

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az cosmosdb mongodb collection create -a {} -g {} -d {} -n {} --shard {} --throughput {} --idx {}

index.json

{
  "indexingMode": "consistent",
  "includedPaths": [
    {
      "path": "/*",
      "indexes": [
        {
          "kind": "Range",
          "dataType": "Number",
          "precision": -1
        },
        {
          "kind": "Range",
          "dataType": "String",
          "precision": -1
        }
      ]
    }
  ],
  "excludedPaths": [
    {
      "path": "/path/to/single/excluded/property/?"
    },
    {
      "path": "/path/to/root/of/multiple/excluded/properties/*"
    }
  ]
}

Expected Behavior

Environment Summary

Windows-10-10.0.17134-SP0
Python 3.6.8
Installer: MSI

azure-cli 2.10.1

Extensions:
azure-devops 0.17.0

Additional Context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MehaKaushikcommented, Aug 18, 2020

Hey @nadworny

  1. For Mongo 3.6 with apiVersion >=2020-04-01 _id is a required index. An index with a single key, equal to _id should be present. “key”: {“keys”: [“_id”]}

  2. When creating indexes using Rest-API for Azure resource manager, there is no way to provide the sorting. By default, the sort order is set to 1. This is a known system limitation and we hope to fix it in the future. But no tentative timeline exists.

0reactions
MehaKaushikcommented, Sep 7, 2020

@nadworny glad to hear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage indexing in Azure Cosmos DB for MongoDB
Unique indexes need to be created while the collection is empty. Unique indexes on nested fields are not supported by default due to...
Read more >
Manage indexing policies in Azure Cosmos DB - Microsoft Learn
In Azure Cosmos DB, data is indexed following indexing policies that are defined for each container. The default indexing policy for newly ...
Read more >
Manage Azure Cosmos DB for NoSQL resources using Azure ...
Create an Azure Cosmos DB container with a custom index policy, a spatial index, composite index, a partition key and RU/s of 400....
Read more >
Create a database and collection for API for MongoDB for ...
Create a database and collection for API for MongoDB for Azure Cosmos DB using Azure CLI · In this article · Prerequisites ·...
Read more >
Create a container in Azure Cosmos DB for NoSQL
It shows how to create a container using the Azure portal, Azure CLI, PowerShell, or supported SDKs. This article demonstrates how to create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found