Skip to content

Azure App Configuration key values not getting refreshed at runtime #1013

@engage-deepakagarwal

Description

@engage-deepakagarwal

Hi,

I have built a simple Microsoft custom engine copilot using Teams AI library in C#

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<AzureADApplication>(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<AzureADApplication> 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?

Metadata

Metadata

Assignees

Labels

.NET Config ProviderIssues related to the AppConfig .NET Core configuration provider.question

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions