How to setup Azure Cosmos DB Emulator as dependency in Visual Studio 2022 Connected Services

Visual Studio team added Azure Cosmos DB Emulator into Connected Services in the Visual Studi version 17.2. This makes life much easier for Cosmos DB developers. In this post, I will share how to configure Cosmos DB Emulator for a project in Visual Studio 2022. You can reach Connected Services from the Project menu or you can right-click on your project and select add then select the connected services to see the options.

You will see the following page after you click on the Connected Service option. As you can see Connected Services already know that I use Azure Cosmos DB in this project. To add a new dependency to my project, I clicked on the plus icon in the Service Dependencies box.

 You should see the Add dependency window after you click on the plus icon. There are great options here, I think the Visual Studio team did a great job by developing this feature. You can easily add Azure Function, Redis, Azure SQL, and of course Azure Cosmos DB as a dependency to your project.



I select the Azure Cosmos DB Emulator from the container from this list. You will see the container information and settings after that.

After you click Next, you should see the connection string for Azure Cosmos DB Emulator. You will need to give a name for the connection string. This will be the name you will use to retrieve connection string from your application. In the following example, my connection string name is localCosmos and I wanted to save the connection string in the local user secrets file.


After you click the Finish button you should see the success message and see the Azure Cosmos DB Emulator in the Service Dependencies list. If you picked the Local user secrets file, you will need to get the connection string from the secrets.json file. Don’t forget to use Singleton when you declare DocumentClient with the connection string!

This blog featured as part of Azure Week. Find more great Azure content here.

About the Author:

Hasan is a Subject Matter Expert on Azure Cosmos DB; he is recognized by Microsoft as Data Platform MVP. He is the owner of SavranWeb Consulting and works at Progressive Insurance as a Business Intelligence Manager. Hasan spends his days architecting cutting edge business solutions by using the latest Web and Database technologies. Hasan has more than 15 years of experience in the software industry as a developer, software architect, manager, and CEO. He has spoken at many conferences worldwide; He is an active member of the HTML5 and Web Assembly W3C groups. Hasan likes to write about SQL, Azure Cosmos DB, C#, and Front-End development on his blog.


Savran, H. (2022). How to setup Azure Cosmos DB Emulator as dependency in Visual Studio 2022 Connected Services. Available at: [Accessed: 24th June 2022]. 

Share this on...

Rate this Post: