如何获取 Azure 函数的 Host.json 文件中的全局设置 [英] How to get the global setting in Host.json file of a Azure function

查看:103
本文介绍了如何获取 Azure 函数的 Host.json 文件中的全局设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 host.json 文件中有一些设置.我知道这是函数应用程序的全局设置.我可以在本地但在生产中获得它.

i have some settings in host.json file. I know that is globla settings for function app. I can get it on local but in production.

在本地,我有这个工作
var maxDequeueCount=config.GetSection("extensions:queues:maxDequeueCount").Value;

In local, i have this work
var maxDequeueCount=config.GetSection("extensions:queues:maxDequeueCount").Value;

有人告诉我如何从 host.json 文件中读取设置吗?

Anyone tell me how to read setting from host.json file?

谢谢

var maxDequeueCount=config.GetSection("extensions:queues:maxDequeueCount").Value;

var maxDequeueCount=config.GetSection("extensions:queues:maxDequeueCount").Value;

推荐答案

这对我有用:

var config = builder.GetContext().Configuration;
string maxAutoRenewDuration = config.GetSection("AzureFunctionsJobHost:extensions:serviceBus:messageHandlerOptions:maxAutoRenewDuration").Value;

这篇关于如何获取 Azure 函数的 Host.json 文件中的全局设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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