Search code examples
azure-cosmosdbazure-cosmosdb-mongoapi

Azure Cosmos DB secret connection strings per database


in my Azure Cosmos DB account, I can add multiple databases (containing multiple collections).

However, I only seem to find account-level connection strings (secrets), that are valid for each database. Differing only in the database name section.

I find this odd. Is this expected? If I want more granular control do I need to create separate accounts for each database?

PS: I'm using the Mongo API if it's somehow relevant.

Cheers


Solution

  • The account-level connection strings you mentioned in the question is master key.Based on this document, Azure Cosmos DB uses two types of keys to authenticate users and provide access to its data and resources.

    enter image description here

    Master keys cannot be used to provide granular access to containers and documents.

    enter image description here

    If you want more granular control,please get an idea of Resource Tokens which provides access to specific containers, partition keys, documents, attachments, stored procedures, triggers, and UDFs.More details,please refer to this link.