Azure Functions how to add application settings to bindings

心已入冬 提交于 2020-07-17 10:10:00

问题


I'm trying to add some custom binding using my app settings for my Azure Function. I need to receive only string a string from my settings.

I would like to get simpleValue from my settings.

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

and the get it in Run method:

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

Is it even possible. Maybe there is other way to do it?


回答1:


I already found the solution. Just add:

using System.Configuration;

and add this line to code with the key ("simpleValue") value:

ConfigurationManager.AppSettings["simpleValue"]



回答2:


App Settings configurations can be referred in binding json as %MY_CUSTOM_CONFIG% - enclosed within percent symbols.

Note that the connection property of triggers and bindings is a special case and automatically resolves values as app settings, without percent signs. https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings



来源:https://stackoverflow.com/questions/40260556/azure-functions-how-to-add-application-settings-to-bindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!