Values from local.settings.json in Azure Functions

这一生的挚爱 提交于 2019-12-10 22:53:43

问题


I've created an Azure function that looks like this (actually, the Microsoft template did most of the work!):

[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("%queue-name%", AccessRights.Listen)]string myQueueItem, TraceWriter log)
{
    log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}

My local.settings.json looks like this:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "..",
    "AzureWebJobsDashboard": "..",
    "AzureWebJobsServiceBus": "..",
    "queue-name":  "testqueue"

  }
}

I then deployed this function. This is a strange SO question, because my problem is that this worked immediately, but I didn't expect it to. The function.json is here:

{
  "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "serviceBusTrigger",
      "queueName": "%queue-name%",
      "accessRights": "listen",
      "name": "myQueueItem"
    }
  ],
  "disabled": false,
  "scriptFile": "..\\bin\\FunctionApp8.dll",
  "entryPoint": "FunctionApp8.Function1.Run"
}

Clearly, the values in local.settings.json have been copied into the function settings, but i can't see them in the portal. My question is: where are these settings now stored (queue-name and AzureWebJobsServiceBus)?

EDIT:

My Application Settings for the function:


回答1:


They'll be under the "Application settings" tab of the published function app in the Azure Portal (see picture).

There's a bit of documentation here! Note that most app settings are not published automatically, and require a bit of configuration either at the publish step or after publishing.


UPDATE: If two functions are listening for an event on the same queue, only one function will be fired. This can cause seemingly buggy behavior, as a function will appear to fire/not fire when expected.

In this case, the unexpected behavior came from a competing functions and not an unexpected connection string.




回答2:


In Azure the function settings are taken from Application settings tab, which is the same as in App Service.

You probably published them too, go check in the portal UI.



来源:https://stackoverflow.com/questions/48649237/values-from-local-settings-json-in-azure-functions

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