Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spring.config.import=azureAppConfiguration
spring.cloud.azure.appconfiguration.stores[0].connection-string=${CONFIG_STORE_CONNECTION_STRING}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ In this section, you clone a containerized Spring Boot application and test it l
az appconfig kv set-keyvault --name myConfigStoreName --key "/application/azure.cosmos.key" --secret-identifier https://myVaultName.vault.azure.net/secrets/COSMOSDB-KEY --yes
```

1. Delete `application.propertes` from `src/main/resources`.
1. Update the application.yml file to now include, removing the other values.

1. Create a new file called `bootstrap.properties` in `src/main/resources`, and add the following.

```properties
```yaml
spring.config.import=azureAppConfiguration
spring.cloud.azure.appconfiguration.stores[0].endpoint=https://{my-configstore-name}.azconfig.io
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Use default application name and no profile configured
# Keys starting with /application/ will be matched
spring:
config:
import: azureAppConfiguration
cloud:
azure:
appconfiguration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@ spring:
config:
message: Hi
feature-management:
Beta: true
dark-theme:
enabled-for:
-
name: Random
parameters:
chance: "50"
beta-ab:
enabled-for:
-
name: Random
parameters:
chance: "50"
-
name: ClientFilter
parameters:
clientIp: 10.0.0.1
feature-flags:
-
id: beta
enabled: true
-
id: dark-theme
enabled: true
conditions:
client-filters:
-
name: Random
parameters:
chance: "50"
-
id: beta-ab
enabled: true
conditions:
client-filters:
-
name: Random
parameters:
chance: "50"
-
name: ClientFilter
parameters:
clientIp: 10.0.0.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
feature-management:
beta:
enabled-for:
- name: Random
parameters:
chance: "80"
feature-flags:
-
id: beta
enabled: true
conditions:
client-filters:
- name: Random
parameters:
chance: "80"
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ description: This sample demonstrates how to refresh configuration properties fr
az appconfig kv set --key /application/config.message --value testKey --name <name-of-your-new-store> --yes
```

1. Create the feature flag in your new store:

```azurecli
az appconfig feature set --feature alpha --name <name-of-your-new-store>
```

1. Create monitor trigger.

```azurecli
Expand Down Expand Up @@ -91,6 +97,28 @@ This value should match the `spring.cloud.azure.appconfiguration.stores[0].monit

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

1. Go to `localhost:8080/feature-flag/alpha` which will display the status of the feature flag.

1. Update the feature flag in your App Configuration store.

```azurecli
az appconfig feature enable --feature alpha --name <name-of-your-new-store>
```

1. Refresh page, this will trigger the refresh update.

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

1. Go to `localhost:8080/feature-flag/alpha` which will display the status of the feature flag.

1. Update the feature flag in your App Configuration store.

```azurecli
az appconfig feature enable --feature alpha --name <name-of-your-new-store>
```

1. After a couple seconds refresh the page twice, this time the feature flag status will show as enabled.

## 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](https://learn.microsoft.com/azure/spring-apps/overview) 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](https://learn.microsoft.com/azure/spring-apps/quickstart?tabs=Azure-CLI).
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.azure.spring.cloud.feature.management.FeatureManager;
import com.fasterxml.jackson.core.JsonProcessingException;

@RestController
Expand All @@ -17,9 +19,21 @@ public class HelloController {
@Autowired
private MessageProperties properties;

@Autowired
private FeatureManager featureManager;

@GetMapping("")
public String getMessage() throws JsonProcessingException {
return properties.getMessage();
}

@GetMapping("/feature-flag/{name}")
public String getFeatureFlag(@PathVariable String name) {
if (featureManager.isEnabled(name)) {
return "Feature flag '" + name + "' is enabled.";
} else {
return "Feature flag '" + name + "' is disabled.";
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
spring.config.import=azureAppConfiguration

spring.cloud.azure.appconfiguration.stores[0].endpoint=${CONFIG_STORE_ENDPOINT}

spring.cloud.azure.appconfiguration.stores[0].feature-flags.enabled=true

spring.cloud.azure.appconfiguration.stores[0].monitoring.enabled=true
spring.cloud.azure.appconfiguration.stores[0].monitoring.refresh-interval=5s
spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key=sentinel

# These will only show when feature flags above are disabled.
feature-management.feature-flags[100].id=gamma
feature-management.feature-flags[100].enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ description: This sample demonstrates how to refresh configuration properties fr
az appconfig kv set --key /application/config.message --value testKey --name <name-of-your-new-store> --yes
```

1. Create the feature flag in your new store:

```azurecli
az appconfig feature set --feature alpha --name <name-of-your-new-store>
```

1. Create monitor trigger.

```azurecli
Expand Down Expand Up @@ -71,6 +77,28 @@ This value should match the `spring.cloud.azure.appconfiguration.stores[0].monit

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

1. Go to `localhost:8080/feature-flag/alpha` which will display the status of the feature flag.

1. Update the feature flag in your App Configuration store.

```azurecli
az appconfig feature enable --feature alpha --name <name-of-your-new-store>
```

1. Refresh page, this will trigger the refresh update.

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

1. Go to `localhost:8080/feature-flag/alpha` which will display the status of the feature flag.

1. Update the feature flag in your App Configuration store.

```azurecli
az appconfig feature enable --feature alpha --name <name-of-your-new-store>
```

1. After a couple seconds refresh the page twice, this time the feature flag status will show as enabled.

## 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](https://learn.microsoft.com/azure/spring-apps/overview) 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](https://learn.microsoft.com/azure/spring-apps/quickstart?tabs=Azure-CLI).
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
spring.config.import=azureAppConfiguration

spring.cloud.azure.appconfiguration.stores[0].connection-string=${CONFIG_STORE_CONNECTION_STRING}

spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filter=,${spring.profiles.active}
spring.cloud.azure.appconfiguration.stores[0].feature-flags.enabled=true

spring.cloud.azure.appconfiguration.stores[0].monitoring.enabled=true
spring.cloud.azure.appconfiguration.stores[0].monitoring.refresh-interval=5s
spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key=sentinel

# These will only show when feature flags above are disabled.
feature-management.feature-flags[100].id=gamma
feature-management.feature-flags[100].enabled=true