Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure app configuration isolated .net 8 LTS function dynamic refresh not working #1022

Open
marcosikkens opened this issue Feb 28, 2025 · 3 comments

Comments

@marcosikkens
Copy link

marcosikkens commented Feb 28, 2025

I created a net 8 lts function app in isolated mode and tried to use azure app configuration. After clicking the new project->function app->net 8 lts isolated with an http trigger i added the following code:

var builder = FunctionsApplication.CreateBuilder(args);

builder.ConfigureFunctionsWebApplication();
builder.Configuration.AddAzureAppConfiguration(o =>
{
    o.Connect(Environment.GetEnvironmentVariable("ConnectionString"));
    o.Select("TestApp:*", LabelFilter.Null);
    o.ConfigureRefresh(refreshOptions =>
        refreshOptions.Register("TestApp:Settings:Sentinel", refreshAll: true).SetRefreshInterval(TimeSpan.FromSeconds(1))
        );
});

builder.Services.AddAzureAppConfiguration();


in my functions class i have the following code:

        public Function1(ILogger<Function1> logger, IConfiguration configuration, IConfigurationRefresherProvider refresherProvider)
        {
            _logger = logger;
            _configuration = configuration;
            _refresherProvider = refresherProvider;
        }

        [Function("Function1")]
        public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
        {
            _logger.LogInformation("C# HTTP trigger function processed a request.");
            return new OkObjectResult($"Welcome to Azure Functions! {_configuration["TestApp:Settings:Message"]}");
        }

AFter updating the sentinel value in my azure configuration the value from the request doesnt change. It DOES change after restarting the function app. I even tried messing with the refresherprovider but calling refreshAsync doesnt change an value. I just copied this from the microsoft documentation, what am I doing wrong?

I am using the 8.1.1 package in my solution.

@juniwang
Copy link

@marcosikkens have you tried to add app.UseAzureAppConfiguration(); in your code? this enables your app to use the App Configuration middleware to update the configuration for you automatically. more examples and details can be found at https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-azure-functions-csharp?tabs=isolated-process and https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-aspnet-core

@marcosikkens
Copy link
Author

marcosikkens commented Feb 28, 2025

@juniwang I cannot do that because that is not an extension method for an Ihost? I am running an isolated function. Also this is not in the example for Azure functions:
https://learn.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-azure-functions-csharp?tabs=in-process

@marcosikkens
Copy link
Author

marcosikkens commented Feb 28, 2025

I also find a lot of results like this:

https://anthonygiretti.com/2024/11/12/from-net-6-to-net-8my-migration-experienceusing-azure-appconfiguration-in-azure-functions-on-net8-isolated/

But in my code the

.ConfigureFunctionsWebApplication(app => { app.UseAzureAppConfiguration(); }

isnt compiling

my csproj is below:

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <!-- Application Insights isn't enabled by default. See https://aka.ms/AAt8mw4. -->
    <!-- <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" /> -->
    <!-- <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.0.0" /> -->
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.1.1" />
  </ItemGroup>```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants