How to create Custom role in CosmosDB API for MongoDB with scope at Database level

Vaikakkara, Anoop 46 Reputation points
2022-03-03T05:18:37.927+00:00

I have a requirement to create Custom roles with assignment scope at database level rather than at Account level in CosmosDB API for MongoDB. I could find documents related to same for SQL API - (https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-setup-rbac) . Is this simply not supported for MongoDB API? Would really appreciate if anyone can suggest on this or share document.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anurag Sharma 17,631 Reputation points
    2022-03-03T11:10:10.713+00:00

    Hi @Vaikakkara, Anoop , welcome to Microsoft Q&A forum.

    From what we understand you want to create custom role in Azure Cosmos DB Mongo API with scope at database level.

    You can refer to below document that provides details on creating the custom role type for mongo DB API.

    az cosmosdb mongodb role definition

    az cosmosdb mongodb role definition create --account-name MyAccount --resource-group MyResourceGroup --body '{  
      "Id": "MyDB.My_Read_Only_Role",  
      "RoleName": "My_Read_Only_Role",  
      "Type": "CustomRole",  
      "DatabaseName": "MyDB",  
      "Privileges": [{  
        "Resource": {  
            "Db": "MyDB",  
            "Collection": "MyCol"  
          },  
          "Actions": [  
            "insert",  
            "find"  
          ]  
      }],  
      "Roles": [  
        {  
          "Role": "myInheritedRole",  
          "Db": "MyTestDb"  
        }  
      ]  
    }'  
    

    Please let us know if this helps or else we can discuss further.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.