c# - Azure Functions 如何将应用程序设置添加到绑定(bind)

标签 c# azure binding settings azure-functions

我正在尝试使用我的 Azure Functions 应用程序设置添加一些自定义绑定(bind)。我只需要从我的设置中接收字符串。

enter image description here

我想从我的设置中获取 simpleValue。

{
   "bindings": [
    {
      "name": "someValue",
      "type": "stringSetting",
      "connection": "simpleValue",
      "direction": "in"
    }
  ],
  "disabled": false
}

并在 Run 方法中获取它:

static void GetOrders(TraceWriter log, string someValue)
{
    log.Info(someValue);
}

有可能吗?也许还有其他方法可以做到这一点?

最佳答案

我已经找到解决方案了。只需添加:

using System.Configuration;

并将此行添加到带有键(“simpleValue”)值的代码中:

ConfigurationManager.AppSettings["simpleValue"]

关于c# - Azure Functions 如何将应用程序设置添加到绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40260556/

相关文章:

c# - SQL插入命令只在一个循环中工作一次

c# - Azure 应用服务上的 ASP.NET Core 应用程序到 Linux

java - 检查数据库数据

c# - 将 AM/PM 时间字符串解析为 TimeSpan

c# - 我是 .Net、C# 和 WPF 程序员。 Expression Blend 值得吗?

c# - 如何编写 linq 语句来获取一组记录中的最后一条记录

Azure Cosmos DB - 超出了每个几何图形允许的最大点数。目前最大支持点数为4096

android - 在 Xamarin Android 名称中绑定(bind)一个 .AAR 不存在

WPF - 尝试根据其初始高度设置可调整大小窗口的 MinHeight

linux - Debian 8.5下无法打开10241端口