1

我一直在尝试将功能标志与 azure 函数一起使用,但我似乎无法正确获取配置。

有一些关于如何获取配置值的文档,但没有关于功能管理的内容。 https://docs.microsoft.com/en-us/azure/azure-app-configuration/use-feature-flags-dotnet-core

4

1 回答 1

2

对的,这是可能的 !

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.AddAzureAppConfiguration(options =>
        {
            options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))
                   // Load all keys that start with `TestApp:`
                   .Select("TestApp:*")
                   // Configure to reload configuration if the registered 'Sentinel' key is modified
                   .ConfigureRefresh(refreshOptions =>
                        refreshOptions.Register("TestApp:Settings:Sentinel", refreshAll: true)
                    )
                   // Indicate to load feature flags
                   .UseFeatureFlags();

参考:https ://github.com/Azure/AppConfiguration/blob/master/examples/DotNetCore/AzureFunction/FunctionApp/Startup.cs

您可以获得IFeatureManagerSnapshot的实例并将其用作 Azure Functions 调用的一部分。

参考: https ://github.com/Azure/AppConfiguration/blob/master/examples/DotNetCore/AzureFunction/FunctionApp/Startup.cs

其他参考:

  1. 在 Azure Functions 中使用 Azure 应用程序配置的功能标志
  2. https://github.com/MicrosoftDocs/azure-docs/issues/52234
于 2020-08-27T08:00:49.943 回答