Skip to content

Latest commit

 

History

History
76 lines (50 loc) · 2.72 KB

File metadata and controls

76 lines (50 loc) · 2.72 KB
page_type languages products name description
sample
java
azure-app-configuration
Refreshing Configuration Properties From App Configuration in Spring Boot Application
This sample demonstrates how to refresh configuration properties from App Configuration in Spring Boot application.

Refreshing Configuration Properties From App Configuration in Spring Boot Application

Prerequisite

How to run

Setup your App Configuration Store

  1. To create your Azure App Configuration store, you can use:

    az appconfig create --resource-group <your-resource-group> --name <name-of-your-new-store> --sku Standard
    
  2. Create the test key in your new store:

    az appconfig kv set --key /application/config.message --value testKey --name <name-of-your-new-store> --yes
    
  3. Create monitor trigger.

    az appconfig kv set --key sentinel --value 1 --name <name-of-your-new-store> --yes
    

This value should match the spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key value in bootstrap.properties.

Run the application

  1. Build the application

    mvn clean package
  2. Run the application

    mvn spring-boot:run
  3. Go to localhost:8080 which will display the value testKey.

  4. Update key to new value.

    az appconfig kv set --key /application/config.message --value updatedTestKey --name <name-of-your-new-store> --yes
    
  5. Update monitor trigger, to trigger refresh.

    az appconfig kv set --key sentinel --value 2 --name <name-of-your-new-store> --yes
    
  6. Refresh page, this will trigger the refresh update.

  7. After a couple seconds refresh again, this time the new value updatedTestKey will show.

Deploy to Azure Spring Apps

Now that you have the Spring Boot application running locally, it's time to move it to production. Azure Spring Apps makes it easy to deploy Spring Boot applications to Azure without any code changes. The service manages the infrastructure of Spring applications so developers can focus on their code. Azure Spring Apps provides lifecycle management using comprehensive monitoring and diagnostics, configuration management, service discovery, CI/CD integration, blue-green deployments, and more. To deploy your application to Azure Spring Apps, see Deploy your first application to Azure Spring Apps.