Skip to content

Latest commit

 

History

History
 
 

spring-cloud-azure-feature-management-sample

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
page_type languages products name description
sample
java
azure-app-configuration
Managing Features and Get Configurations From App Configuration in Spring Boot Application
This sample demonstrates how to manage features and how to get configurations from App Configuration to Spring Environment in Spring Boot application.

Managing Features and Get Configurations From App Configuration in Spring Boot Application

This sample describes how to use spring-cloud-azure-feature-management to manage features and how to get configurations from App Configuration Service to Spring Environment.

Key concepts

Getting started

spring-cloud-azure-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.

How to run without App Configuration Service

Start the application and check the resulting console output to check the returned value.

  1. Load features from application.yml
mvn spring-boot:run
  1. Check the returned value. The feature Beta has one filter Random which defines the Beta feature will be activated randomly with some chance value. You should see the following information displayed: RUNNING : application or RUNNING : beta.

How to run with Azure Configuration Service

Prepare data

  1. Create a Configuration Store if not exist.
az appconfig create --resource-group <your-resource-group> --name <name-of-your-new-store> --sku Standard
  1. Import the data file src/main/resources/data/sample-data.json into the Configuration Store created above. Under For language select Other. Under File type select Yaml or 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.

Updating the application

  1. Add the spring-cloud-azure-appconfiguration-config dependency,
<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>spring-cloud-azure-appconfiguration-config</artifactId>
    <version>4.19.0</version>
</dependency>
  1. 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>
  1. Delete application.yml.

Run the application

  1. Load features from application.yml
mvn spring-boot:run
  1. Check the returned value. The feature Beta has one filter Random which defines the Beta feature will be activated randomly with some chance value. You should see the following information displayed: RUNNING : application or RUNNING : beta.

More details

Please refer to this README about more usage details.

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.

Examples

Troubleshooting

Next steps

Contributing