| page_type | sample | |
|---|---|---|
| languages |
|
|
| products |
|
|
| name | Refreshing Configuration Properties From App Configuration in Spring Boot Application using Entra ID | |
| description | This sample demonstrates how to refresh configuration properties from App Configuration in Spring Boot application using Entra ID. |
- A Java Development Kit (JDK), version 8.
- Apache Maven, version 3.0 or later.
-
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 -
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 -
Create the feature flag in your new store:
az appconfig feature set --feature alpha --name <name-of-your-new-store> -
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.
-
Set an environment variable named APP_CONFIGURATION_ENDPOINT, and set it to the endpoint to your App Configuration store. At the command line, run the following command and restart the command prompt to allow the change to take effect:
setx APP_CONFIGURATION_ENDPOINT "endpoint-of-your-app-configuration-store"
If you use Windows PowerShell, run the following command:
$Env:APP_CONFIGURATION_ENDPOINT = "endpoint-of-your-app-configuration-store"If you use macOS or Linux, run the following command:
export APP_CONFIGURATION_ENDPOINT='endpoint-of-your-app-configuration-store'
-
Build the application
mvn clean package -
Run the application
mvn spring-boot:run -
Go to
localhost:8080which will display the valuetestKey. -
Update key to new value.
az appconfig kv set --key /application/config.message --value updatedTestKey --name <name-of-your-new-store> --yes -
Update monitor trigger, to trigger refresh.
az appconfig kv set --key sentinel --value 2 --name <name-of-your-new-store> --yes -
Refresh page, this will trigger the refresh update.
-
After a couple seconds refresh again, this time the new value
updatedTestKeywill show. -
Go to
localhost:8080/feature-flag/alphawhich will display the status of the feature flag. -
Update the feature flag in your App Configuration store.
az appconfig feature enable --feature alpha --name <name-of-your-new-store> -
Refresh page, this will trigger the refresh update.
-
After a couple seconds refresh again, this time the new value
updatedTestKeywill show. -
Go to
localhost:8080/feature-flag/alphawhich will display the status of the feature flag. -
Update the feature flag in your App Configuration store.
az appconfig feature enable --feature alpha --name <name-of-your-new-store> -
After a couple seconds refresh the page twice, this time the feature flag status will show as enabled.
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.