Skip to content

Commit b568bc1

Browse files
committed
Add request scoping samples
1 parent 2499d15 commit b568bc1

File tree

4 files changed

+265
-0
lines changed

4 files changed

+265
-0
lines changed
30 KB
Loading
29.2 KB
Loading
24.2 KB
Loading

docs/AzureFrontDoor/readme.md

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
## CDN-Accelerated Configuration Delivery with Azure Front Door
2+
3+
App Configuration gives developers a single, consistent place to define configuration settings and feature flags. By integrating Azure App Configuration with Azure Front Door, your configuration data is centrally managed through Azure App Configuration while being cached and distributed through Azure's content delivery network. This architecture is valuable for client-facing applications including mobile, desktop, and browser-based applications.
4+
5+
## Documentation links
6+
7+
- Conceptual overview of [Hyperscale Configuration](https://learn.microsoft.com/azure/azure-app-configuration/concept-hyperscale-client-config)
8+
- [Connect App Config to Azure Front Door](https://learn.microsoft.com/azure/azure-app-configuration/how-to-connect-azure-front-door)
9+
- [Connect applications to Azure Front Door](https://learn.microsoft.com/azure/azure-app-configuration/how-to-load-azure-front-door-configprovider)
10+
11+
12+
## Request scoping filter samples
13+
14+
The key-value filters used by your application must match exactly the filters configured for the Azure Front Door endpoint; any mismatch will cause the request to be rejected. For example, if your endpoint is configured to allow access to keys starting with an "App1:" prefix, the application code must also load keys starting with "App1:". However, if your application loads keys starting with a more specific prefix like "App1:Prod:", the request is rejected.
15+
16+
Here are some examples to help you set up the right filters.
17+
18+
- [Application uses key-values only](#application-uses-key-values-only)
19+
- [Application uses feature flags only](#application-uses-feature-flags-only)
20+
- [Application uses key-values and feature flags](#application-uses-key-values-and-feature-flags)
21+
- [Application uses multiple key-value selectors](#application-uses-multiple-key-value-selectors)
22+
- [Application uses key-values and snapshot selectors](#application-uses-key-values-and-snapshot-selectors)
23+
- [Application uses snapshot reference](#application-uses-snapshot-reference)
24+
- [Application loads key-values with reserved characters](#application-loads-key-values-with-reserved-characters)
25+
- [Application loads key-values with tag filters](#application-loads-key-values-with-tag-filters)
26+
27+
28+
### Application uses key-values only
29+
30+
If you application has the following set up:
31+
32+
```cs
33+
builder.Configuration.AddAzureAppConfiguration(options =>
34+
{
35+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
36+
.Select("App1:*")
37+
.ConfigureRefresh(refreshOptions =>
38+
{
39+
refreshOptions.RegisterAll()
40+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
41+
});
42+
});
43+
```
44+
45+
Then your Azure Front Door filters should look like this:
46+
47+
48+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
49+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
50+
| Key value | Key Starts with | `App1:` | Label Equal | `(No label)` |
51+
52+
53+
![AFD Portal Filters](./images/sample1.png)
54+
55+
-------
56+
57+
### Application uses feature flags only
58+
59+
If you application has the following set up for loading only feature flags:
60+
61+
```cs
62+
builder.Configuration.AddAzureAppConfiguration(options =>
63+
{
64+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
65+
.UseFeatureFlags(ffOptions =>
66+
{
67+
ffOptions.Select("MyFeatures*")
68+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
69+
});
70+
});
71+
```
72+
73+
Then your Azure Front Door filters should look like this:
74+
75+
76+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
77+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
78+
| Key value | Key All | `*` | Label Equal | `(No label)` |
79+
| Key value | Key Starts with | `.appconfig.featureflag/MyFeatures` | Label Equal | `(No label)` |
80+
81+
-------
82+
83+
### Application uses key-values and feature flags
84+
85+
If you application has the following set up for loading key-values and feature flags:
86+
87+
```cs
88+
builder.Configuration.AddAzureAppConfiguration(options =>
89+
{
90+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
91+
.Select("App1:*")
92+
.ConfigureRefresh(refreshOptions =>
93+
{
94+
refreshOptions.RegisterAll()
95+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
96+
})
97+
.UseFeatureFlags(ffOptions =>
98+
{
99+
ffOptions.Select("MyFeatures*")
100+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
101+
});
102+
});
103+
```
104+
105+
Then your Azure Front Door filters should look like this:
106+
107+
108+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
109+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
110+
| Key value | Key Starts with | `App1:` | Label Equal | `(No label)` |
111+
| Key value | Key Starts with | `.appconfig.featureflag/MyFeatures` | Label Equal | `(No label)` |
112+
113+
-------
114+
115+
### Application uses multiple key-value selectors
116+
117+
If you application has the following set up with multiple selectors:
118+
119+
```cs
120+
builder.Configuration.AddAzureAppConfiguration(options =>
121+
{
122+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
123+
.Select("App1:*")
124+
.Select("Global*", "App1Label")
125+
.ConfigureRefresh(refreshOptions =>
126+
{
127+
refreshOptions.RegisterAll()
128+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
129+
});
130+
});
131+
```
132+
133+
Then your Azure Front Door filters should look like this:
134+
135+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
136+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
137+
| Key value | Key Starts with | `App1:` | Label Equal | `(No label)` |
138+
| Key value | Key Starts with | `Global` | Label Equal | `App1Label` |
139+
140+
-------
141+
142+
### Application uses key-values and snapshot selectors
143+
144+
If you application has the following set up with key-values and snapshot:
145+
146+
```cs
147+
builder.Configuration.AddAzureAppConfiguration(options =>
148+
{
149+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
150+
.Select("App1:*")
151+
.SelectSnapshot("MySnapshot")
152+
.ConfigureRefresh(refreshOptions =>
153+
{
154+
refreshOptions.RegisterAll()
155+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
156+
});
157+
});
158+
```
159+
160+
Then your Azure Front Door filters should look like this:
161+
162+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
163+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
164+
| Key value | Key Starts with | `App1:` | Label Equal | `(No label)` |
165+
| Snapshot | Snapshot name | `MySnapshot` | - | - |
166+
167+
-------
168+
169+
### Application uses snapshot reference
170+
171+
If your application loads a key-value that is a [snapshot reference](https://learn.microsoft.com/azure/azure-app-configuration/concept-snapshot-references), Azure Front Door must be configured to allowlist the referenced snapshot. Include the snapshot name in your Azure Front Door filters to enable snapshot resolution. For example, if you have the following set up:
172+
173+
```cs
174+
builder.Configuration.AddAzureAppConfiguration(options =>
175+
{
176+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
177+
.Select("App1:*")
178+
.ConfigureRefresh(refreshOptions =>
179+
{
180+
refreshOptions.RegisterAll()
181+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
182+
});
183+
});
184+
```
185+
186+
Lets say, one of the loaded key-values is a snapshot reference that looks like this:
187+
188+
```json
189+
{
190+
"key": "App1:MySnapshotReference",
191+
"label": null,
192+
"value": "{\"snapshot_name\":\"snapshot1\"}",
193+
"content_type": "application/json; profile=\"https://azconfig.io/mime-profiles/snapshot-ref\"; charset=utf-8",
194+
"tags": {}
195+
}
196+
```
197+
198+
Then you need to add "snapshot1" to your Azure Front Door filters, in addition to the key-value filter.
199+
200+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
201+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
202+
| Key value | Key Starts with | `App1:` | Label Equal | `(No label)` |
203+
| Snapshot | Snapshot name | `snapshot1` | - | - |
204+
205+
-------
206+
207+
### Application loads key-values with reserved characters
208+
209+
If you application has the following set up where your key filter contains App Config reserved characters (`, * \`):
210+
211+
```cs
212+
builder.Configuration.AddAzureAppConfiguration(options =>
213+
{
214+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
215+
.Select("App1\\*Prefix*")
216+
.ConfigureRefresh(refreshOptions =>
217+
{
218+
refreshOptions.RegisterAll()
219+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
220+
});
221+
});
222+
```
223+
224+
Then your Azure Front Door filters should look like this:
225+
226+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** |
227+
| ---------------- | ------------- | ----------- | ------------- | ----------- |
228+
| Key value | Key Starts with | `App1\*Prefix` | Label Equal | `(No label)` |
229+
230+
231+
![AFD Portal Filters](./images/sample2.png)
232+
233+
-------
234+
235+
### Application loads key-values with tag filters
236+
237+
If you application has the following set up with tag filters:
238+
239+
```cs
240+
builder.Configuration.AddAzureAppConfiguration(options =>
241+
{
242+
options.ConnectAzureFrontDoor(new Uri("{YOUR-AFD-ENDPOINT}"))
243+
.Select("App1:*", tagFilters: new[] { "Env=Dev" })
244+
.ConfigureRefresh(refreshOptions =>
245+
{
246+
refreshOptions.RegisterAll()
247+
.SetRefreshInterval(TimeSpan.FromMinutes(1));
248+
});
249+
});
250+
```
251+
252+
Then your Azure Front Door filters should look like this:
253+
254+
| **Filter Type** | **Operator** | **Value** | **Operator** | **Value** | **Operator** | **Value** |
255+
| ---------------- | ------------- | ----------- | ------------- | ----------- | ------------- | ----------- |
256+
| Key value | Key Starts with | `App1:` | Label Equal | `(No label)` | Tags | Name: `Env`, Value: `Dev` |
257+
258+
![AFD Portal Filters](./images/sample3.png)
259+
260+
-------
261+
262+
## Sample Applications
263+
264+
- [.NET MAUI](https://github.com/Azure-Samples/appconfig-maui-app-with-afd/blob/main/README.md)
265+
- [JavaScript](https://github.com/Azure-Samples/appconfig-javascript-clientapp-with-afd/blob/main/README.md)

0 commit comments

Comments
 (0)