Azure / Azure/AppConfiguration

Azure App Configuration key values not getting refreshed at runtime

Open
#1,013 3 comments 0 reactions 1 assignee Claimed by @amerjusupovic View on GitHub
.NET Config Provider question
Dominant language
No language data
Stars
263
Forks
82
Avg merge
3d 15h
Merged PRs (30d)
6

Description

Hi,

I have built a simple [Microsoft custom engine copilot using Teams AI library in C#](https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/teams-conversational-ai/conversation-ai-quick-start?context=%2Fmicrosoft-365-copilot%2Fextensibility%2Fcontext&tabs=OpenAI-key%2COpenAI-key2&pivots=qs-csharp)

I tried to integrate with Azure App Configuration into this app with below code snippet in my Program.cs

```
//More about sentinel configuration key -
//https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core#add-a-sentinel-key
builder.Configuration.AddAzureAppConfiguration(options =>
options
.Connect(new Uri(appConfiguration.AzureAppConfiguration.Url), tokenCredential)
.Select(KeyFilter.Any, appConfiguration.AzureAppConfiguration.EnvironmentLabel)
.ConfigureRefresh(refreshOptions =>
refreshOptions
.Register("TestApp:SentinelKey", appConfiguration.AzureAppConfiguration.EnvironmentLabel, refreshAll: true)
.SetRefreshInterval(TimeSpan.FromSeconds(5))));
builder.Services.AddAzureAppConfiguration();

builder.Services.Configure(builder.Configuration.GetSection(Constants.AppConfigurationPrefix.AzureADApplication));
```

And then later in the same Program.cs file -

```
WebApplication app = builder.Build();
app.UseAzureAppConfiguration();
```

Class definition of AzureADApplication -
```
public class AzureADApplication
{
public string Type { get; set; }
}
```

Using it like below in the Bot Action code -

```
public CustomCopilotBotActions(
IOptionsSnapshot appConfiguration,
IServiceProvider serviceProvider)
{
this.appConfiguration = appConfiguration.Value;
}
```

Created App Configuration resource in Azure which has a sample configuration like

- _Key: "AzureADApplication:Type", Value: "abc", Label: "DEV"_
- _Key: "TestApp:SentinelKey", Value: "1", Label: "DEV"_

Everything works fine when application starts-up (Bot side loaded in Teams), I could see the values loaded into "appConfiguration" in the constructor above. However, if I change the value in "AzureADApplication:Type" on Azure and then update the sentinel key as well, the next request to the application (even after 5, 10 etc. seconds) doesn't get this reflected value in "Type" property of appConfiguration in the constructor above (the constructor gets called of-course for every request).

It works fine with the sample application with console/webapp provided as part of Azure App Configuration documentation but not in this. Not sure what I'm missing here. Could this be specifically related to Bot and/or Teams AI Library SDK? Doesn't think so.
Thoughts?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.