This sample describes how to use spring-cloud-feature-management to manage features and how to get configurations from App Configuration Service to Spring Environment.
azure-spring-cloud-feature-management doesn't require use of the App Configuration service, but can be integrated with it. The next section shows how to use the library without the App Configuration service, the section after shows how to update the example to use it with the App Configuration service.
Start the application and check the resulting console output to check the returned value.
- Load features from application.yml
mvn spring-boot:run
- Check the returned value. The feature
Betahas one filterRandomwhich defines the Beta feature will be activated randomly with some chance value. You should see the following information displayed: RUNNING : application or RUNNING : beta.
- Create a Configuration Store if not exist.
az appconfig create --resource-group <your-resource-group> --name <name-of-your-new-store> --sku Standard
- Import the data file src/main/resources/data/sample-data.json into the Configuration Store created above. Under
For languageselectOther. UnderFile typeselectYamlor using the azure cli:
az appconfig kv import -n <name-of-your-new-store> -s file --path <location-of-your-properties-file> --format properties --prefix /application/
It will have you confirm the feature flag before loading it.
- Add the azure-spring-cloud-appconfiguration-config dependency,
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-cloud-appconfiguration-config</artifactId>
<version>2.3.0</version>
</dependency>- Create a file named bootstrap.properties in the resources folder and add the connection string to it.
spring.cloud.azure.appconfiguration.stores[0].connection-string= <your-connection-string>Note: You can get your connection string from the portal from Access Keys or using the cli:
az appconfig credential list --resource-group <your-resource-group> --name <name-of-your-new-store>
- Delete application.yml.
- Load features from application.yml
mvn spring-boot:run
- Check the returned value. The feature
Betahas one filterRandomwhich defines the Beta feature will be activated randomly with some chance value. You should see the following information displayed: RUNNING : application or RUNNING : beta.
Please refer to this README about more usage details.