Standard Azure Storage Queue trigger line …

public async void ProcessQueueMessage([QueueTrigger("queue-abc")] string message, ILogger logger)

Question: I would like to set the “QueueTrigger”-value (queue-abc) during the initial load of a Azure WebJob, based on a value in appsetting.json.

I am writing in .Net Core 3.1

Is this possible?

Added after Answer: https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to#custom-binding-expressions

1

There are 1 answers

0
rickvdbosch On BEST ANSWER

If you want to use a setting from appsettings.json (or from the Function App's Application Settings for that matter), you can use the name of the setting surrounded by percent signs in the trigger attribute.

For example:

appsettings.json

{
  "Values": {
    "QUEUENAME": "SomeQueueName"
  }
}

Azure Function

[FunctionName("QueueTrigger")]
public static void Run(
    [QueueTrigger("%QUEUENAME%")]string myQueueItem, 
    ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}