Skip to content

Commit 6f0239f

Browse files
authored
Merge pull request #311198 from linglingye001/linglingye/audience-guide
[App Configuration] - Guidance on how to configure audience
2 parents 5234d09 + 9492827 commit 6f0239f

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

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

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

108+
### [JavaScript](#tab/javascript)
109+
110+
The Audience for the target cloud must be configured for the following packages.
111+
112+
- Azure SDK for JavaScript: @azure/app-configuration >= 1.9.0
113+
- JavaScript configuration provider: @azure/app-configuration-provider >= 1.0.0
114+
115+
In the **Azure SDK for JavaScript**, audience is configured by passing the `audience` option to the `AppConfigurationClient` constructor.
116+
117+
The following code snippet demonstrates how to instantiate a configuration client with a cloud-specific audience.
118+
119+
```javascript
120+
const client = new AppConfigurationClient(myStoreEndpoint, new DefaultAzureCredential(), {
121+
audience: "{Cloud specific audience here}",
122+
});
123+
```
124+
125+
In the **JavaScript configuration provider**, audience is configured by passing the `clientOptions` with the `audience` property to the `load` function.
126+
127+
The following code snippet demonstrates how to load Azure App Configuration in a JavaScript application with a cloud-specific audience.
128+
129+
```javascript
130+
const appConfig = await load(myStoreEndpoint, credential, {
131+
clientOptions: {
132+
audience: "{Cloud specific audience here}"
133+
}
134+
});
135+
```
136+
137+
### [Go](#tab/go)
138+
139+
The Audience for the target cloud must be configured for the following packages.
140+
141+
- Azure SDK for Go: azappconfig >= 2.1.0
142+
- Go configuration provider: azureappconfiguration >= 1.0.0
143+
144+
You need to import the following packages:
145+
146+
```golang
147+
import (
148+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
149+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
150+
)
151+
```
152+
153+
In the **Azure SDK for Go**, audience is configured by utilizing the cloud configuration.
154+
155+
The following code snippet demonstrates how to instantiate a configuration client with a cloud-specific audience.
156+
157+
```golang
158+
credential, _:= azidentity.NewDefaultAzureCredential(nil)
159+
160+
cloudConfig := cloud.Configuration{
161+
Services: map[cloud.ServiceName]cloud.ServiceConfiguration{
162+
azappconfig.ServiceName: {
163+
Audience: "{Cloud specific audience here}",
164+
},
165+
},
166+
}
167+
168+
clientOptions := &azappconfig.ClientOptions{
169+
ClientOptions: policy.ClientOptions{
170+
Cloud: cloudConfig,
171+
},
172+
}
173+
174+
client, _ := azappconfig.NewClient(myStoreEndpoint, credential, clientOptions)
175+
```
176+
177+
In the **Go configuration provider**, audience is configured by passing the `ClientOptions` with the cloud configuration to the `Load` function.
178+
179+
The following code snippet demonstrates how to load Azure App Configuration in a Go application with a cloud-specific audience.
180+
181+
```golang
182+
credential, _:= azidentity.NewDefaultAzureCredential(nil)
183+
184+
authOptions := azureappconfiguration.AuthenticationOptions{
185+
Endpoint: myStoreEndpoint,
186+
Credential: credential,
187+
}
188+
189+
cloudConfig := cloud.Configuration{
190+
Services: map[cloud.ServiceName]cloud.ServiceConfiguration{
191+
azappconfig.ServiceName: {
192+
Audience: "{Cloud specific audience here}",
193+
},
194+
},
195+
}
196+
197+
options := &azureappconfiguration.Options{
198+
ClientOptions: &azappconfig.ClientOptions{
199+
ClientOptions: policy.ClientOptions{
200+
Cloud: cloudConfig,
201+
},
202+
},
203+
}
204+
205+
appConfig, _ := azureappconfiguration.Load(context.Background(), authOptions, options)
206+
```
207+
108208
---
109209

110210
### Audience

0 commit comments

Comments
 (0)