Skip to content

Commit e950bac

Browse files
committed
aad and version updates
1 parent 785d47b commit e950bac

6 files changed

+223
-231
lines changed

articles/azure-app-configuration/enable-dynamic-configuration-java-spring-app.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: mrm9084
77
ms.service: azure-app-configuration
88
ms.devlang: java
99
ms.topic: tutorial
10-
ms.date: 03/07/2024
10+
ms.date: 12/04/2024
1111
ms.custom: devx-track-java, devx-track-extended-java
1212
ms.author: mametcal
1313
#Customer intent: As a Java Spring developer, I want to dynamically update my app to use the latest configuration data in App Configuration.
@@ -115,30 +115,14 @@ To use automated refresh, start with a Spring Boot app that uses App Configurati
115115
116116
Then, open the *pom.xml* file in a text editor and add a `<dependency>` for `spring-cloud-azure-appconfiguration-config-web` using the following code.
117117
118-
**Spring Boot**
119-
120-
### [Spring Boot 3](#tab/spring-boot-3)
121-
122-
```xml
123-
<dependency>
124-
<groupId>com.azure.spring</groupId>
125-
<artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
126-
<version>5.8.0</version>
127-
</dependency>
128-
```
129-
130-
### [Spring Boot 2](#tab/spring-boot-2)
131-
132118
```xml
133119
<dependency>
134120
<groupId>com.azure.spring</groupId>
135121
<artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
136-
<version>4.14.0</version>
122+
<version>5.18.0</version>
137123
</dependency>
138124
```
139125
140-
---
141-
142126
1. Update `bootstrap.properties` to enable refresh
143127
144128
```properties

articles/azure-app-configuration/enable-dynamic-configuration-java-spring-push-refresh.md

Lines changed: 107 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: azure-app-configuration
99
ms.devlang: java
1010
ms.custom: devx-track-extended-java
1111
ms.topic: tutorial
12-
ms.date: 03/07/2024
12+
ms.date: 12/04/2024
1313
ms.author: mametcal
1414
#Customer intent: I want to use push refresh to dynamically update my app to use the latest configuration data in App Configuration.
1515
---
@@ -46,82 +46,85 @@ In this tutorial, you learn how to:
4646

4747
1. Open *pom.xml* and update the file with the following dependencies.
4848

49-
### [Spring Boot 3](#tab/spring-boot-3)
50-
51-
```xml
52-
<dependency>
53-
<groupId>com.azure.spring</groupId>
54-
<artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
55-
</dependency>
56-
57-
<!-- Adds the Ability to Push Refresh -->
58-
<dependency>
59-
<groupId>org.springframework.boot</groupId>
60-
<artifactId>spring-boot-starter-actuator</artifactId>
61-
</dependency>
62-
63-
<dependencyManagement>
64-
<dependencies>
65-
<dependency>
66-
<groupId>com.azure.spring</groupId>
67-
<artifactId>spring-cloud-azure-dependencies</artifactId>
68-
<version>5.8.0</version>
69-
<type>pom</type>
70-
<scope>import</scope>
71-
</dependency>
72-
</dependencies>
73-
</dependencyManagement>
74-
```
75-
76-
### [Spring Boot 2](#tab/spring-boot-2)
77-
78-
```xml
79-
<dependency>
49+
```xml
50+
<dependency>
51+
<groupId>com.azure.spring</groupId>
52+
<artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
53+
</dependency>
54+
55+
<!-- Adds the Ability to Push Refresh -->
56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-starter-actuator</artifactId>
59+
</dependency>
60+
61+
<dependencyManagement>
62+
<dependencies>
63+
<dependency>
8064
<groupId>com.azure.spring</groupId>
81-
<artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
82-
</dependency>
83-
84-
<!-- Adds the Ability to Push Refresh -->
85-
<dependency>
86-
<groupId>org.springframework.boot</groupId>
87-
<artifactId>spring-boot-starter-actuator</artifactId>
88-
</dependency>
89-
90-
<dependencyManagement>
91-
<dependencies>
92-
<dependency>
93-
<groupId>com.azure.spring</groupId>
94-
<artifactId>spring-cloud-azure-dependencies</artifactId>
95-
<version>4.14.0</version>
96-
<type>pom</type>
97-
<scope>import</scope>
98-
</dependency>
99-
</dependencies>
100-
</dependencyManagement>
101-
```
102-
103-
---
104-
65+
<artifactId>spring-cloud-azure-dependencies</artifactId>
66+
<version>5.18.0</version>
67+
<type>pom</type>
68+
<scope>import</scope>
69+
</dependency>
70+
</dependencies>
71+
</dependencyManagement>
72+
```
10573

10674
1. Set up [Maven App Service Deployment](../app-service/quickstart-java.md?tabs=javase) so the application can be deployed to Azure App Service via Maven.
10775

10876
```console
10977
mvn com.microsoft.azure:azure-webapp-maven-plugin:2.5.0:config
11078
```
11179

112-
1. Open bootstrap.properties and configure Azure App Configuration Push Refresh.
80+
1. Navigate to the `resources` directory of your app and open `bootstrap.properties` and configure Azure App Configuration Push Refresh. If the file does not exist, create it. Add the following line to the file.
11381

114-
```properties
115-
# Azure App Configuration Properties
116-
spring.cloud.azure.appconfiguration.stores[0].connection-string= ${AppConfigurationConnectionString}
117-
spring.cloud.azure.appconfiguration.stores[0].monitoring.enabled= true
118-
spring.cloud.azure.appconfiguration.stores[0].monitoring.refresh-interval= 30d
119-
spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key= sentinel
120-
spring.cloud.azure.appconfiguration.stores[0].monitoring.push-notification.primary-token.name= myToken
121-
spring.cloud.azure.appconfiguration.stores[0].monitoring.push-notification.primary-token.secret= myTokenSecret
82+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
83+
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:
84+
85+
```properties
86+
spring.cloud.azure.appconfiguration.stores[0].endpoint= ${APP_CONFIGURATION_ENDPOINT}
87+
spring.cloud.azure.appconfiguration.stores[0].monitoring.enabled= true
88+
spring.cloud.azure.appconfiguration.stores[0].monitoring.refresh-interval= 30d
89+
spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key= sentinel
90+
spring.cloud.azure.appconfiguration.stores[0].monitoring.push-notification.primary-token.name= myToken
91+
spring.cloud.azure.appconfiguration.stores[0].monitoring.push-notification.primary-token.secret= myTokenSecret
12292

123-
management.endpoints.web.exposure.include= appconfiguration-refresh
124-
```
93+
management.endpoints.web.exposure.include= appconfiguration-refresh
94+
```
95+
96+
Additionally, you need to add the following code to your project, unless you want to use just Managed Identity:
97+
98+
```java
99+
import org.springframework.stereotype.Component;
100+
101+
import com.azure.core.credential.TokenCredential;
102+
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
103+
import com.azure.identity.IntelliJCredentialBuilder;
104+
import com.azure.spring.cloud.appconfiguration.config.ConfigurationClientCustomizer;
105+
106+
@Component
107+
public class AppConfigCredential implements ConfigurationClientCustomizer {
108+
109+
@Override
110+
public void customize(ConfigurationClientBuilder builder, String endpoint) {
111+
builder.credential(new DefaultAzureCredentialBuilder().build());
112+
}
113+
}
114+
```
115+
116+
### [Connection string](#tab/connection-string)
117+
```properties
118+
spring.cloud.azure.appconfiguration.stores[0].endpoint= ${APP_CONFIGURATION_CONNECTION_STRING}
119+
spring.cloud.azure.appconfiguration.stores[0].monitoring.enabled= true
120+
spring.cloud.azure.appconfiguration.stores[0].monitoring.refresh-interval= 30d
121+
spring.cloud.azure.appconfiguration.stores[0].monitoring.triggers[0].key= sentinel
122+
spring.cloud.azure.appconfiguration.stores[0].monitoring.push-notification.primary-token.name= myToken
123+
spring.cloud.azure.appconfiguration.stores[0].monitoring.push-notification.primary-token.secret= myTokenSecret
124+
125+
management.endpoints.web.exposure.include= appconfiguration-refresh
126+
```
127+
---
125128

126129
A random delay is added before the cached value is marked as dirty to reduce potential throttling. The default maximum delay before the cached value is marked as dirty is 30 seconds.
127130

@@ -132,26 +135,55 @@ A random delay is added before the cached value is marked as dirty to reduce pot
132135

133136
Event Grid Web Hooks require validation on creation. You can validate by following this [guide](../event-grid/webhook-event-delivery.md) or by starting your application with Azure App Configuration Spring Web Library already configured, which will register your application for you. To use an event subscription, follow the steps in the next two sections.
134137

135-
1. Set the environment variable to your App Configuration instance's connection string:
138+
1. Set an environment variable.
136139

137-
#### [Windows command prompt](#tab/cmd)
140+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
141+
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.
142+
143+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
138144

139145
```cmd
140-
setx AppConfigurationConnectionString <connection-string-of-your-app-configuration-store>
146+
setx APP_CONFIGURATION_ENDPOINT "endpoint-of-your-app-configuration-store"
141147
```
142148

143-
#### [PowerShell](#tab/powershell)
149+
If you use PowerShell, run the following command:
144150

145-
```PowerShell
146-
$Env:AppConfigurationConnectionString = <connection-string-of-your-app-configuration-store>
151+
```powershell
152+
$Env:APP_CONFIGURATION_ENDPOINT = "endpoint-of-your-app-configuration-store"
147153
```
148154

149-
#### [Bash](#tab/bash)
155+
If you use macOS or Linux, run the following command:
150156

151157
```bash
152-
export AppConfigurationConnectionString = <connection-string-of-your-app-configuration-store>
158+
export APP_CONFIGURATION_ENDPOINT='endpoint-of-your-app-configuration-store'
159+
```
160+
161+
### [Connection string](#tab/connection-string)
162+
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.
163+
164+
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
165+
166+
```cmd
167+
setx APP_CONFIGURATION_CONNECTION_STRING "connection-string-of-your-app-configuration-store"
168+
```
169+
170+
If you use PowerShell, run the following command:
171+
172+
```powershell
173+
$Env:APP_CONFIGURATION_CONNECTION_STRING = "connection-string-of-your-app-configuration-store"
153174
```
154175

176+
If you use macOS or Linux, run the following command:
177+
178+
```bash
179+
export APP_CONFIGURATION_CONNECTION_STRING='connection-string-of-your-app-configuration-store'
180+
```
181+
---
182+
183+
Restart the command prompt to allow the change to take effect. Print the value of the environment variable to validate that it is set properly.
184+
185+
---
186+
155187
1. Update your `pom.xml` under the `azure-webapp-maven-plugin`'s `configuration` add
156188
157189
```xml

0 commit comments

Comments
 (0)