Connection String for individual databases in Azure CosmosDB for MongoDB vCore

Akunuri, Vithal 20 Reputation points
2025-11-25T13:19:56.7+00:00

Hi,

As advised in the response to my question at https://learn.microsoft.com/en-gb/answers/questions/5629583/how-to-create-a-custom-role-for-secondary-user-in, created secondary users at cluster level in Azure CosmosDB for MongoDB vCore. In our setup, we have 5 databases created in the same cluster.

Is it possible to connect to individual database as mentioned in the documentation https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/connect-account#get-the-mongodb-connection-string-to-customize

If not, can you please confirm if connecting to the server is the only way in vCore setup as mentioned at https://docs.azure.cn/en-us/cosmos-db/mongodb/vcore/how-to-connect-studio-3t#connect-by-using-studio-3t

Thanks,

Vithal

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
{count} votes

2 answers

Sort by: Most helpful
  1. Manoj Kumar Boyini 1,330 Reputation points Microsoft External Staff Moderator
    2025-11-25T15:03:59.64+00:00

    Hi Akunuri, Vithal

    Thank you for reaching out to Microsoft QA. In Azure Cosmos DB for MongoDB vCore, it isn’t possible to create a connection string for just one specific database. You have to use the cluster-level connection string provided in the Azure portal. Once you’re connected, you can select the database you need within your client or application.

    User permissions are set up at the cluster level, so you can control which databases each user has access to this is all managed by their roles, not by the connection string itself.

    Helpful References:

    How to get the MongoDB connection string and customize it

    Service limits and authentication in vCore

    Connecting with Studio 3T

    Hope this helps. Do let us know if you have any further queries.

    1 person found this answer helpful.
    0 comments No comments

  2. Q&A Assist
    2025-11-25T13:20:07.65+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Yes, it is possible to connect to individual databases in Azure Cosmos DB for MongoDB vCore. You can customize the MongoDB connection string to specify the database you want to connect to. The connection string format allows you to include the database name as part of the URI. If you do not specify a database in the connection string, it will default to "test."

    The connection string format is as follows:

    mongodb://username:password@host:port/[database]?ssl=true
    

    In this format, you can replace [database] with the name of the specific database you wish to connect to.

    If you need to connect to the server, you can also do so, but connecting directly to an individual database is supported and may be more convenient for your use case.


    References:

    0 comments No comments

Your answer

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