Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Values from local.settings.json in Azure Functions

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:

App Settings

like image 943
Paul Michaels Avatar asked Mar 07 '23 23:03

Paul Michaels


1 Answers

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.

Application settings


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.

like image 110
Marie Hoeger Avatar answered Mar 12 '23 09:03

Marie Hoeger