Skip to content

Commit 8f8ab40

Browse files
committed
Update concept-enable-rbac.md
1 parent 6d87fbf commit 8f8ab40

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

articles/azure-app-configuration/concept-enable-rbac.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,75 @@ builder.AddAzureAppConfiguration(o =>
105105
});
106106
```
107107

108+
### [Java](#tab/java)
109+
110+
The Audience for the target cloud must be configured for the following packages.
111+
112+
- Azure SDK for Java: azure-data-appconfiguration >= 1.8.0
113+
- Java configuration provider: spring-cloud-azure-appconfiguration-config >= 5.22.0
114+
115+
In the **Azure SDK for Java**, audience is configured by passing the `audience` option to the `ConfigurationClientBuilder` when building a `ConfigurationClient`.
116+
117+
The following code snippet demonstrates how to instantiate a configuration client with a cloud-specific audience.
118+
119+
```java
120+
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
121+
.endpoint(myStoreEndpoint)
122+
.credential(new DefaultAzureCredentialBuilder().build())
123+
.audience(ConfigurationAudience.fromString("{Cloud specific audience here}"))
124+
.buildClient();
125+
```
126+
127+
In the **Spring configuration provider**, audience is configured by customizing the `ConfigurationClientBuilder` through the `ConfigurationClientCustomizer` interface, then adding it to the bootstrap registry.
128+
129+
The following code snippet demonstrates how to add the Azure App Configuration provider into a Spring Boot application with a cloud-specific audience.
130+
131+
```java
132+
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
133+
import com.azure.data.appconfiguration.models.ConfigurationAudience;
134+
import com.azure.spring.cloud.appconfiguration.config.ConfigurationClientCustomizer;
135+
136+
public class CustomClient implements ConfigurationClientCustomizer {
137+
138+
139+
@Override
140+
public void customize(ConfigurationClientBuilder builder, String endpoint) {
141+
builder.audience(ConfigurationAudience.fromString("{Cloud specific audience here}"));
142+
}
143+
}
144+
```
145+
146+
Then, register the `CustomClient` in the bootstrap registry.
147+
148+
```java
149+
import org.springframework.boot.SpringApplication;
150+
import org.springframework.boot.autoconfigure.AutoConfiguration;
151+
import org.springframework.boot.autoconfigure.SpringBootApplication;
152+
153+
import hello.impl.AppConfigClientImpl;
154+
155+
@SpringBootApplication
156+
@AutoConfiguration
157+
public class Application {
158+
159+
public static void main(String[] args) {
160+
SpringApplication app = new SpringApplication(Application.class);
161+
162+
// Register the ConfigurationClientCustomizer in the bootstrap context
163+
app.addBootstrapRegistryInitializer(registry -> {
164+
registry.register(CustomClient.class, context -> new CustomClient());
165+
});
166+
167+
app.run(args);
168+
}
169+
170+
}
171+
```
172+
173+
> [!NOTE]
174+
> This same approach is used for configuring the audience the Spring configuration provider uses for modifying the `SecretClient` when Key Vault is used as a reference in App Configuration. Just implement a `SecretClientCustomizer` and register it in the bootstrap registry to configure the audience for Key Vault references.
175+
176+
108177
### [JavaScript](#tab/javascript)
109178

110179
The Audience for the target cloud must be configured for the following packages.

0 commit comments

Comments
 (0)