设置文件中的Azure使用者组 [英] Azure Consumer Group From Settings File

查看:75
本文介绍了设置文件中的Azure使用者组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于C#天蓝色功能,我们希望仅更改一次即可重用同一功能,这就是目标消费者组.理想情况下,我们可以将使用者组设置为通过local.settings.json加载的环境变量.但是,这些设置不会作为常量读入.消费者组必须恒定才能使人满意.

For a C# azure function, we wish to re-use the same function with only a single change which is the target consumer group. Ideally we could set the consumer group in an environmental variable that is loaded through local.settings.json. However, these settings are not read in as constants. The consumer group must be constant in order to comiple.

一个人如何从设置文件加载到使用者组中?

How does one load in a consumer group from a settings file?

推荐答案

在您的 function.json 文件中,您可以在符号内指定使用者组名称:

In your function.json file you can specify consumer group name inside % symbol:

{
    ...
    "consumerGroup": "%groupname%"
    ...
}

,然后添加具有相应名称(在本例中为 groupname )的Application设置.然后,消费者组将在启动时解析为设置名称.

and then add an Application setting with corresponding name (groupname in this case). Consumer group will then be resolved to the setting name at startup.

当然,如果使用预编译的.NET函数,您也可以这样做:

Of course, you can do the same if you use precompiled .NET functions:

[EventHubTrigger("samples-workitems", Connection = "EventHubConnectionAppSetting", 
                                      ConsumerGroup = "%groupname%")]

这篇关于设置文件中的Azure使用者组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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