You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Customer intent: As a Java Spring developer, I want to dynamically update my app to use the latest configuration data in App Configuration.
@@ -29,7 +29,7 @@ Refresh allows you to update your configuration values without having to restart
29
29
30
30
To use manual refresh, start with a Spring Boot app that uses App Configuration, such as the app you create by following the [Spring Boot quickstart for App Configuration](quickstart-java-spring-app.md).
31
31
32
-
App Configuration exposes `AppConfigurationRefresh`, which can be used to check if the cache is expired. If it's expired, a refresh is triggered.
32
+
App Configuration exposes `AppConfigurationRefresh`, which checks if the refresh interval has passed. If the refresh interval has passed, it triggers a refresh.
33
33
34
34
1. To use `AppConfigurationRefresh`, update HelloController.
35
35
@@ -59,6 +59,13 @@ App Configuration exposes `AppConfigurationRefresh`, which can be used to check
59
59
60
60
`AppConfigurationRefresh`'s `refreshConfigurations()` returns a `Mono` that is true if a refresh is triggered, and false if not. False means either the cache expiration time isn't expired, there was no change, or another thread is currently checking for a refresh.
61
61
62
+
> [!NOTE]
63
+
>For libraries such as SpringWebFlux that require non-blocking calls, `refreshConfigurations()` needs to be wrapped in a thread as loading configurations requires a blocking call.
@@ -106,8 +113,8 @@ App Configuration exposes `AppConfigurationRefresh`, which can be used to check
106
113
107
114
1. Refresh the browser page twice to see the new message displayed. The first time triggers the refresh, the second loads the changes.
108
115
109
-
> [!NOTE]
110
-
>The library only checks for changes on the after the refresh interval has passed. If the period hasn't passed then no change is displayed. Wait for the period to pass, then trigger the refresh check.
116
+
> [!NOTE]
117
+
>The library checks for changes only after the refresh interval passes. If the refresh interval hasn't passed, it doesn't check for changes. Waitfor the interval to pass, then trigger the refresh check.
111
118
112
119
## Use automated refresh
113
120
@@ -119,7 +126,7 @@ Then, open the *pom.xml* file in a text editor and add a `<dependency>` for `spr
@@ -170,8 +177,8 @@ Then, open the *pom.xml* file in a text editor and add a `<dependency>` for `spr
170
177
171
178
1. Refresh the browser page twice to see the new message displayed. The first time triggers the refresh, the second loads the changes, as the first request returns using the original scope.
172
179
173
-
> [!NOTE]
174
-
> The library only checks for changes on after the refresh interval has passed. If the refresh interval hasn't passed, then it doesn't check for changes. Wait for the interval to pass, then trigger the refresh check.
180
+
> [!NOTE]
181
+
> The library checks for changes only after the refresh interval passes. If the refresh interval hasn't passed, it doesn't check for changes. Wait for the interval to pass, then trigger the refresh check.
@@ -80,68 +80,87 @@ To create a new Spring Boot project:
80
80
```
81
81
82
82
> [!NOTE]
83
-
> * There is a non-web Feature Management Library that doesn't have a dependency on spring-web. Refer to GitHub's [documentation](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/spring/spring-cloud-azure-feature-management) for differences.
83
+
> * There's a non-web Feature Management Library that doesn't have a dependency on spring-web. Refer to GitHub's [documentation](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/spring/spring-cloud-azure-feature-management) for differences.
84
84
85
85
## Connect to an App Configuration store
86
86
87
+
1. Navigate to the `resources` directory of your app and open the `bootstrap.properties` or `bootstrap.yaml` file. If the file doesn't exist, create it.
87
88
88
-
1. Navigate to the `resources` directory of your app and open the `bootstrap.properties` or `bootstrap.yaml` file. If the file does not exist, create it. Add the following line to the file.
89
-
90
-
### [Microsoft Entra ID (recommended)](#tab/entra-id)
91
-
You use the `DefaultAzureCredential` to authenticate to your App Configuration store. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role. Be sure to allow sufficient time for the permission to propagate before running your application. Create a new file named *AppConfigCredential.java* and add the following lines:
92
-
93
-
If you are using a properties file, use the following code:
If you're using a yaml file, use the following code:
101
+
```yaml
102
+
spring:
103
+
cloud:
104
+
azure:
105
+
appconfiguration:
106
+
stores:
107
+
-
108
+
feature-flags:
109
+
enabled: true
110
+
endpoint: ${APP_CONFIGURATION_ENDPOINT}
111
+
```
112
+
113
+
You use the `DefaultAzureCredential` to authenticate to your App Configuration store. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role. Be sure to allow sufficient time for the permission to propagate before running your application.
114
+
115
+
1. Add the following code to your project, unless you want to use Managed Identity. Create a new file named `AppConfigCredential.java`:
And add configuration Bootstrap Configuration, by creating `spring.factories` file under `resources/META-INF` directory and add the following lines and updating `com.example.MyApplication` with your application name and package:
149
+
1. Add configuration Bootstrap Configuration, by creating `spring.factories` file under `resources/META-INF` directory and add the following lines and updating `com.example.MyConfiguration` with your application package:
If you are using a yaml file, use the following code:
163
+
If you are using a yaml file, use the following code:
145
164
```yaml
146
165
spring:
147
166
cloud:
@@ -154,81 +173,28 @@ To create a new Spring Boot project:
154
173
```
155
174
---
156
175
157
-
1. Set an environment variable.
158
-
159
-
### [Microsoft Entra ID (recommended)](#tab/entra-id)
160
-
Set the environment variable named **APP_CONFIGURATION_ENDPOINT** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
161
-
162
-
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
Set the environment variable named **APP_CONFIGURATION_CONNECTION_STRING** to the read-only connection string of your App Configuration store found under *Access keys* of your store in the Azure portal.
182
-
183
-
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
@@ -326,6 +292,56 @@ To create a new Spring Boot project:
326
292
327
293
## Build and run the app locally
328
294
295
+
1. Set an environment variable.
296
+
297
+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
298
+
Set the environment variable named **APP_CONFIGURATION_ENDPOINT** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
299
+
300
+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
Set the environment variable named **APP_CONFIGURATION_CONNECTION_STRING** to the read-only connection string of your App Configuration store found under *Access settings* of your store in the Azure portal.
321
+
322
+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
0 commit comments