Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
The Basic, Standard, and Enterprise plans will be deprecated starting from mid-March, 2025, with a 3 year retirement period. We recommend transitioning to Azure Container Apps. For more information, see the Azure Spring Apps retirement announcement.
The Standard consumption and dedicated plan will be deprecated starting September 30, 2024, with a complete shutdown after six months. We recommend transitioning to Azure Container Apps. For more information, see Migrate Azure Spring Apps Standard consumption and dedicated plan to Azure Container Apps.
This article applies to: ✅ Java ✅ C#
This article applies to: ✅ Basic/Standard ✅ Enterprise
Instead of manually configuring your Spring Boot applications, you can automatically connect selected Azure services to your applications by using Azure Spring Apps. This article shows how to connect your application to Azure Cache for Redis.
If you don't have a deployed Azure Spring Apps instance, follow the steps in the Quickstart: Deploy your first application to Azure Spring Apps.
Add the following dependency to your project's pom.xml file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
Remove any spring.redis.*
properties from the application.properties file
Update the current deployment using az spring app update
or create a new deployment using az spring app deployment create
.
Note
By default, Service Connectors are created at the application level. To override the connections, you can create other connections again in the deployments.
Use the Azure CLI to configure your Spring app to connect to a Redis database with an access key using the az spring connection create
command, as shown in the following example.
az spring connection create redis \
--resource-group $AZURE_SPRING_APPS_RESOURCE_GROUP \
--service $AZURE_SPRING_APPS_SERVICE_INSTANCE_NAME \
--app $APP_NAME \
--deployment $DEPLOYMENT_NAME \
--target-resource-group $REDIS_RESOURCE_GROUP \
--server $REDIS_SERVER_NAME\
--database $REDIS_DATABASE_NAME \
--secret
Note
If you're using Service Connector for the first time, start by running the command az provider register --namespace Microsoft.ServiceLinker
to register the Service Connector resource provider.
If you're using Redis Enterprise, use the az spring connection create redis-enterprise
command instead.
Tip
Run the command az spring connection list-support-types --output table
to get a list of supported target services and authentication methods for Azure Spring Apps. If the az spring
command isn't recognized by the system, check that you have installed the required extension by running az extension add --name spring
.
Alternatively, you can use the Azure portal to configure this connection by completing the following steps. The Azure portal provides the same capabilities as the Azure CLI and provides an interactive experience.
Select your Azure Spring Apps instance in the Azure portal and then select Apps from the navigation menu. Choose the app you want to connect and then select Service Connector on the navigation menu.
Select Create.
On the Basics tab, for service type, select Cache for Redis. Choose a subscription and a Redis cache server. Fill in the Redis database name ("0" in this example) and under client type, select Java. Select Next: Authentication.
On the Authentication tab, choose Connection string. Service Connector automatically retrieves the access key from your Redis database account. Select Next: Networking.
On the Networking tab, select Configure firewall rules to enable access to target service, then select Review + Create.
On the Review + Create tab, wait for the validation to pass and then select Create. The creation can take a few minutes to complete.
Once the connection between your Spring app your Redis database has been generated, you can see it in the Service Connector page and select the unfold button to view the configured connection variables.
In this article, you learned how to connect your application in Azure Spring Apps to Azure Cache for Redis. To learn more about connecting services to your application, see Connect to an Azure Database for MySQL instance.
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Accelerate a Spring Boot application with Azure Cache for Redis - Training
Learn how to use Azure Cache for Redis to cache business data and HTTP session data in a Java Spring Boot application, then publish the application to the cloud.
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.
Documentation
Use Azure Redis Cache in Spring - Java on Azure
Configure a Spring Boot application created with the Spring Initializr to use the Redis in the cloud with Azure Cache for Redis.
Spring Cloud Azure Redis support - Java on Azure
This article describes how Spring Cloud Azure and Azure Redis can be used together.
Quickstart: Use Azure Cache for Redis in Java - Azure Cache for Redis
In this quickstart, you create a new Java app that uses Azure Cache for Redis