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: I want to dynamically update my .NET background service to use the latest configuration data in App Configuration.
15
15
---
@@ -70,8 +70,39 @@ You use the [.NET command-line interface (CLI)](/dotnet/core/tools/) to create a
70
70
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
71
71
```
72
72
73
-
1. Connect to App Configuration.
73
+
1. Connect to App Configuration using Microsoft Entra ID (recommended), or a connection string.
74
74
75
+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
76
+
77
+
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.
78
+
79
+
```csharp
80
+
// Existing code in Program.cs
81
+
// ... ...
82
+
83
+
var builder = Host.CreateApplicationBuilder(args);
@@ -96,6 +127,7 @@ You use the [.NET command-line interface (CLI)](/dotnet/core/tools/) to create a
96
127
// The rest of existing code in Program.cs
97
128
// ... ...
98
129
```
130
+
---
99
131
100
132
In the `ConfigureRefresh` method, a key within your App Configuration store is registered for change monitoring. The `Register` method has an optional boolean parameter `refreshAll` that can be used to indicate whether all configuration values should be refreshed if the registered key changes. In this example, only the key *TestApp:Settings:Message* will be refreshed. All settings registered for refresh have a default cache expiration of 30 seconds before a new refresh is attempted. It can be updated by calling the `AzureAppConfigurationRefreshOptions.SetCacheExpiration` method.
101
133
@@ -137,42 +169,49 @@ You use the [.NET command-line interface (CLI)](/dotnet/core/tools/) to create a
137
169
138
170
## Build and run the app locally
139
171
140
-
1. Set an environment variable named **ConnectionString**, and set it to the access key to your App Configuration store. At the command line, run the following command.
### [Microsoft Entra ID (recommended)](#tab/entra-id)
175
+
Set the environment variable named **Endpoint** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
143
176
144
-
To build and run the app locally using the Windows command prompt, run the following command.
177
+
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 **ConnectionString** to the read-only connection string of your App Configuration store found under *Access keys* of your store in the Azure portal.
161
197
162
-
If you use macOS, run the following command.
198
+
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