Mer*_*roz 11 c# settings binding azure azure-functions
我正在尝试使用我的Azure功能的应用程序设置添加一些自定义绑定.我需要从我的设置中只收到一个字符串.
我想从我的设置中获得simpleValue.
{
"bindings": [
{
"name": "someValue",
"type": "stringSetting",
"connection": "simpleValue",
"direction": "in"
}
],
"disabled": false
}
Run Code Online (Sandbox Code Playgroud)
并在Run方法中获取它:
static void GetOrders(TraceWriter log, string someValue)
{
log.Info(someValue);
}
Run Code Online (Sandbox Code Playgroud)
它甚至可能吗?也许有其他方法可以做到这一点?
Mer*_*roz 21
我已经找到了解决方案.只需添加:
using System.Configuration;
Run Code Online (Sandbox Code Playgroud)
并使用键("simpleValue")值将此行添加到代码中:
ConfigurationManager.AppSettings["simpleValue"]
Run Code Online (Sandbox Code Playgroud)
应用设置配置可以在绑定 json 中引用为 %MY_CUSTOM_CONFIG% - 包含在百分比符号中。
请注意,触发器和绑定的连接属性是一种特殊情况,它会自动将值解析为应用程序设置,没有百分号。 https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings
| 归档时间: |
|
| 查看次数: |
8130 次 |
| 最近记录: |