Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 2.46 KB

enable-dynamic-configuration-java-spring-app.md

File metadata and controls

55 lines (40 loc) · 2.46 KB
title titleSuffix description services author ms.service ms.topic ms.date ms.author
Use dynamic configuration in a Spring Boot app
Azure App Configuration
Learn how to dynamically update configuration data for Spring Boot apps
azure-app-configuration
lisaguthrie
azure-app-configuration
tutorial
3/5/2020
lcozzens

Tutorial: Use dynamic configuration in a Java Spring app

The App Configuration Spring Boot client library supports updating a set of configuration settings on demand, without causing an application to restart. The client library caches each setting to avoid too many calls to the configuration store. The refresh operation doesn't update the value until the cached value has expired, even when the value has changed in the configuration store. The default expiration time for each request is 30 seconds. It can be overridden if necessary.

You can check for updated settings on demand by calling AppConfigurationRefresh's refreshConfigurations() method.

Alternatively, you can use the spring-cloud-azure-appconfiguration-config-web package, which takes a dependency on spring-web to handle automated refresh.

Use automated refresh

To use automated refresh, start with a Spring Boot app that uses App Configuration, such as the app you create by following the Spring Boot quickstart for App Configuration.

Then, open the pom.xml file in a text editor, and add a <dependency> for spring-cloud-azure-appconfiguration-config-web.

Spring Cloud 1.1.x

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
    <version>1.1.2</version>
</dependency>

Spring Cloud 1.2.x

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
    <version>1.2.2</version>
</dependency>

Save the file, then build and run your application as usual.

Next steps

In this tutorial, you enabled your Spring Boot app to dynamically refresh configuration settings from App Configuration. To learn how to use an Azure managed identity to streamline the access to App Configuration, continue to the next tutorial.

[!div class="nextstepaction"] Managed identity integration