Visual Studio Connected Services enables developers to easily connect and integrate with several services. We have seen several connected services including Application Insights, Azure Storage, Mobile services etc. Similarly, you can connect Azure Cosmos DB accounts from Visual Studio using the connected services. Visual Studio Connected Services allows adding Cosmos DB account to your project and start building application quickly.
Through the connected service, you can quickly create and query document. You can also create an Azure Cosmos DB account in Connected Service tool. To connect Azure Cosmos DB with your Visual Studio project
- Create a new project / open an existing project in Visual Studio.
- Select the Connected Services option by right clicking on References -> Connected Services
If you don’t find the Azure Cosmos DB Connected services, search & Install it in Visual Studio Marketplace. You can achieve that through either via clicking “find more services” options or navigating to “Extension & Updates” option from the Tools Menu.
Once you have the “Azure Cosmos DB” service installed / available, select it. You will find your all Azure Cosmos DB services are listed for the Azure subscription your are signed in for.
Choose the specific Azure Cosmos DB account to add to your project and select the “Add” button.
You can also add a new Cosmos DB Account from this wizard by selecting “Create a New Cosmos DB Account”
Visual Studio will now add all the necessary files in your project and download all the required NuGet packages to work with.
Visual Studio also updates the Cosmos DB connection URI’s and key’s to the project’s App.config file
That’s it. And with that, your project is ready to connect and work with Cosmos DB. You can include the Microsoft.Azure.Documents.Client namespace in your application and start working your Cosmos DB API’s
We will explore more on programming with Cosmos DB API in a separate post.
Azure Cosmos DB Connected services tools provide some additional features including creating new documents and work with Azure CosmosDB resources. Go ahead, install and start exploring this tool.
Other Tips Related to Azure Cosmos DB:
- Working with Azure Storage Explorer for Azure Cosmos DB
- Connecting Azure Cosmos DB with Azure Storage Explorer by using Connection String
- Working with Azure Cosmos DB using Visual Studio Code
- Add an Azure Cosmos DB trigger to an existing Azure Function app from Azure Cosmos DB Portal
- Setting up global replication of your Azure Cosmos DB database using the Azure portal
- Setting up Failover Priorities for Azure Cosmos DB from Azure Portal
Hope this helps.