在Azure函数中使用Azure应用配置的功能标志 [英] Usage of Azure App Configuration's Feature Flags in Azure Functions

查看:71
本文介绍了在Azure函数中使用Azure应用配置的功能标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Azure函数的Http触发器中Azure应用配置的以下2个功能

I'm working on exploring the following 2 features of Azure App Configuration in Azure Function's Http Trigger

  1. 外部化应用设置
  2. 功能标志

下面是我如何获取配置参考

Below is how i'm getting the reference of the configuration

因此,当我使用_configuration ["SomeAppSettingKey"]时,我可以检索该值.因此,我能够实现上面提到的#1功能.

So, when I use _configuration["SomeAppSettingKey"], I'm able to retrieve the value. So, I'm able to achieve #1 feature mentioned above.

我的问题是,我们如何检索功能标志信息?我尝试了以下方法.

My Question is, How do we retrieve the Feature Flag information? I have tried the below ways.

如果有人可以帮助我了解如何在Azure Functions中检索它(我正在使用V3),我将不胜感激?示例代码或对文档的任何引用都将有所帮助.

I would appreciate if someone could help me in understanding how to retrieve it in Azure Functions (I'm using V3)? A Sample code or any reference to documentation would be helpful.

谢谢.

Update1:我可以反序列化json内容,如下所示.但是,这是正确的方法吗?

Update1: I can deserialize the json content as shown below. But, is this is the right approach?

其中FeatureManager是我已定义的类,如下所示.

Where FeatureManager is a class that I have defined as shown below.

推荐答案

所有您需要的是调用 UseFeatureFlags()函数作为 AddAzureAppConfiguration 的一部分,以使应用程序配置提供程序知道您要使用功能标志.您可以在下面的链接中找到一个示例.它使用 FunctionsStartup 和Azure Functions的依赖项注入(DI).功能管理器的一个实例被放到DI中.

all you need is to call UseFeatureFlags() function as part of AddAzureAppConfiguration to let the App Configuration provider know you want to use feature flags. An example can be found following the link below. It uses the FunctionsStartup and dependency injection (DI) of Azure Functions. An instance of a feature manager is put into the DI.

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

下面的链接显示了如何从DI获取 IFeatureManagerSnapshot 的实例并将其用作Azure Functions调用的一部分.

The link below shows how you can obtain the instance of IFeatureManagerSnapshot from DI and use it as part of your Azure Functions call.

https://github.com/Azure/AppConfiguration/blob/master/examples/DotNetCore/AzureFunction/FunctionApp/ShowBetaFeature.cs

这篇关于在Azure函数中使用Azure应用配置的功能标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆