Cannot create a mongodb collection using azure cli with an index policy
See original GitHub issueThis 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:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @nadworny
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”]}
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.
@nadworny glad to hear.