Tutorial: Bind an Azure Cosmos DB to your Azure Spring Cloud application

Azure Spring Cloud allows you to bind select Azure services to your applications automatically, instead of manually configuring your Spring Boot application. This article demonstrates how to bind your application to an Azure Cosmos DB.


  • A deployed Azure Spring Cloud instance. Follow our quickstart to get started.
  • An Azure Cosmos DB account with a minimum permissions level of contributor.

Bind Azure Cosmos DB

Azure Cosmos DB has five different API types that support binding:

  1. Create an Azure Cosmos DB database. Refer to this article for help with creating the database. Record the name of your database. Ours is named testdb.

  2. Add one of the following dependencies in your Spring Cloud application's pom.xml according to your API type.

    API type: Core (SQL)


    API type: MongoDB


    API type: Cassandra


    API type: Gremlin (graph)


    API type: Azure Table

  3. Update the current deployment using az spring-cloud app update or create a new deployment for this change using az spring-cloud app deployment create. These commands will either update or create the application with the new dependency.

  4. Go to your Azure Spring Cloud service page in the Azure portal. This is the same application you updated or deployed in the previous step. Find the Application Dashboard and select the application to bind to the Cosmos DB. Next, select Service binding and select the Create service binding button. Fill out the form, selecting Binding type Azure Cosmos DB, the API type, your database name, and the Azure Cosmos DB account.


    Use a key space for the database name if you are using Cassandra.

  5. Restart the application by selecting the Restart button on the application page.

  6. To ensure the service is bound correctly, select the binding name and verify its detail. The property field should be similar to this:

    azure.cosmosdb.uri=https:/<some account>.documents.azure.com:443

Next steps

In this tutorial, you learned how to bind your Azure Spring Cloud application to a CosmosDB. To learn how to bind your application to an Azure Redis Cache, continue to the next tutorial.