0
votes

I am trying to restore a dumped DB on Cosmos using mongorestore command but unfortunately it is throwing an error as follows:

error running create command: (Unauthorized) Error=13, Details='Response status code does not indicate success: Forbidden (403); Substatus: 0; ActivityId: 421d33eb-dea0-4372-92b0-ece63fd2b357; Reason: ("Operation 'POST' on resource 'dbs' is not allowed through Azure Cosmos DB endpoint. Please switch on such operations for your account, or perform this operation through Azure Resource Manager, Azure Portal, Azure CLI or Azure Powershell" ActivityId: 421d33eb-dea0-4372-92b0-ece63fd2b357, Microsoft.Azure.Documents.Common/2.11.0, Please see CosmosDiagnostics, Windows/10.0.14393 cosmos-netstandard-sdk/3.3.2); 2020-08-25T20:47:42.088+0530 0 document(s) restored successfully. 0 document(s) failed to restore.

I am following this link provided by Microsoft to migrate data: https://azure.microsoft.com/en-in/resources/videos/using-mongodb-tools-with-azure-cosmos-db/

The command used for restoring the DB is as follows:

mongorestore --host HOSTNAME:PORT -u USERNAME -p PASSWORD --db DBNAME DUMPED_DB_DIRECTORY_PATH --ssl --sslAllowInvalidCertificates

Without using collection

With using collection

Which account it is referring to enable the operation and How do I enable the operation on my account as highlighted by the logs ? Is there any equivalent of mongorestore in Azure CLI or Portal ?

I tried restoring a single collection also but the same error came up. I was successfully able to dump the data from my another Cosmos DB instance.

1
Which API did you specify when creating your Cosmos DB instance: MongoDB API or SQL API?David Makogon
It's MongoDB API and mongodump was also successful.Soulshifter
Ok, great - it would help if you edited your question to show your actual mongorestore command line (just be sure to obfuscate your actual endpoint name and key). As written, it's not entirely clear what that looks like. Also, are you specifying a collection name?David Makogon
I edited the question with attached screenshots for the commands. I used both with and without specifying collection name. Without specifying the collection name and just passing the DB folder, mongorestore was able to identify all the collections in it. But apparently, the same error occurs in both the cases.Soulshifter

1 Answers

0
votes

It was a problem from the Azure policy side. The Azure policy respective to the Cosmos DB which prevents key based metadata write access was enabled hence, not able to do any changes in the DB. The organisation put that policy in place, now it is resolved after disabling the policy.