Connect an Azure Database for MySQL instance to your application in Azure Spring Apps

Note

The Basic, Standard plans entered a retirement period on March 17, 2025. For more information, see the Azure Spring Apps retirement announcement.

The Standard consumption and dedicated plan entered a retirement period on September 30, 2024, with a complete shutdown by the end of March 2025.

With Azure Spring Apps, you can connect selected Azure services to your applications automatically, instead of having to configure your Spring Boot application manually. This article shows you how to connect your application to your Azure Database for MySQL instance.

Prerequisites

Prepare your project

  1. In your project's pom.xml file, add the following dependency:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.azure.spring</groupId>
        <artifactId>spring-cloud-azure-starter-jdbc-mysql</artifactId>
    </dependency>
    
  2. In the application.properties file, remove any spring.datasource.* properties.

  3. Update the current app by running az spring app deploy, or create a new deployment for this change by running az spring app deployment create.

Connect your app to the Azure Database for MySQL instance

Next steps

In this article, you learned how to connect an application in Azure Spring Apps to an Azure Database for MySQL instance. To learn more about connecting services to an application, see Connect an Azure Cosmos DB database to an application in Azure Spring Apps.