Home > Software design >  Azure functions: is it possible to give multiple parameters to a queue trigger?
Azure functions: is it possible to give multiple parameters to a queue trigger?

Time:03-16

I am very new to Azure Functions. I have a HTTP triggered function. From this http triggered function, I need to invoke a queue triggered function. I was wondering when invoking queue trigger, can I pass more than one parameter?

Below is my current function.json and run.ps1 of queue trigger

{
  "bindings": [
    {
      "name": "Jobname",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "JobQueue"
    }
  ]
}

run.ps1

param([string] $Jobname, $TriggerMetadata)

To invoke queue trigger inside HTTP triggered function, I am using below command

Push-OutputBinding -Name JobQueue -Value $value

CodePudding user response:

Method 1

From Azure docs found below code to send multiple messages at once from run.ps1 file in HTTP trigger

$message = @("message1", "message2")
Push-OutputBinding -Name Msg -Value $message

But in above method, there was no reference for using the Msg variable at run.ps1of Queue trigger.

Method 2

Code in run.ps1 and function.json files of HTTP Trigger

Push-OutputBinding -Name QueueItem1 -Value $message1
Push-OutputBinding -Name QueueItem2 -Value $message2

function.json

   {
      "type": "queue",
      "direction": "out",
      "name": "QueueItem1",
      "connection": "<Storage>",
      "queueName": "egqueue"
    },
    {
      "type": "queue",
      "direction": "out",
      "name": "QueueItem2",
      "connection": "<Storage>",
      "queueName": "egqueue"
    }

Note: Both methods created separate entries with separate ID's in Storage Queue

  • Related