Alex Gordon
Alex Gordon

Reputation: 60691

is it possible to parameterize QueueTrigger name?

I'm writing a queue-triggered azure function:

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

The name of the queue is translationsqueue, but I'd like to be able to parameterize this.

How do we pull the name of the queue from configuration?

Upvotes: 1

Views: 539

Answers (1)

Roman Kiss
Roman Kiss

Reputation: 8235

Based on the Binding expressions and patterns the app setting binding expression is wrapped in percent signs, see the following example:

in the class:

QueueTrigger("%translationsqueue%", …) 

in the bindings:

    {
      "bindings": [
       {
         "name": "myQueueItem",
         "type": "queueTrigger",
         "direction": "in",
         "queueName": "%translationsqueue%",
         "connection": "TranslationsQueueConnectionString"
       }
      ]
   }

Upvotes: 3

Related Questions