Skip to content

Commit e2a114a

Browse files
committed
Review
1 parent 95a0929 commit e2a114a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

articles/azure-app-configuration/enable-dynamic-configuration-dotnet-background-service.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: azure-app-configuration
99
ms.devlang: csharp
1010
ms.custom: devx-track-csharp, devx-track-dotnet
1111
ms.topic: tutorial
12-
ms.date: 02/20/2024
12+
ms.date: 11/12/2024
1313
ms.author: zhiyuanliang
1414
#Customer intent: I want to dynamically update my .NET background service to use the latest configuration data in App Configuration.
1515
---
@@ -73,19 +73,27 @@ You use the [.NET command-line interface (CLI)](/dotnet/core/tools/) to create a
7373
1. Connect to App Configuration using Microsoft Entra ID (recommended), or a connection string.
7474
7575
### [Microsoft Entra ID (recommended)](#tab/entra-id)
76+
77+
You use the `DefaultAzureCredential` to authenticate to your App Configuration store.
78+
79+
1. 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.
80+
81+
1. Update the code in Program.cs.
82+
7683
```csharp
7784
// Existing code in Program.cs
7885
// ... ...
7986
8087
var builder = Host.CreateApplicationBuilder(args);
8188
82-
builder.Configuration.AddAzureAppConfiguration(options =>
89+
builder.Configuration.AddAzureAppConfiguration(options =>
8390
{
84-
options.Connect(new DefaultAzureCredential())
91+
string endpoint = Environment.GetEnvironmentVariable("Endpoint");
92+
options.Connect(new Uri(endpoint), new DefaultAzureCredential());
8593
// Load all keys that start with `TestApp:`.
8694
.Select("TestApp:*")
8795
// Configure to reload the key 'TestApp:Settings:Message' if it is modified.
88-
.ConfigureRefresh(refreshOptions =>
96+
.ConfigureRefresh(refreshOptions =>
8997
{
9098
refreshOptions.Register("TestApp:Settings:Message");
9199
});

0 commit comments

Comments
 (0)