简体   繁体   中英

Azure powershell function how to add message to storage account queue

I have the basic Azure function and in the integration I have defined trigger as Azure storage queue and parameter name as queueItem. Likewise I have set output as Azure storage queue and parameter name as outputQueueItem. Function is triggered when I get message to my inputqueue but I cannot get the message to outputqueue.

param([string] $QueueItem, $TriggerMetadata)
Write-Host "PowerShell queue trigger function processed work item: $QueueItem"
Write-Host "Queue item insertion time: $($TriggerMetadata.InsertionTime)"

$outputQueueItem = $QueueItem

I have tried with "$outputQueueItem.Add($QueueItem)" but none of these work. What is the correct way on using the output?

You can try in my way, it works fine on my side:

run.ps1 :

# Input bindings are passed in via param block.
param([string] $QueueItem, $TriggerMetadata)

# Write out the queue message and insertion time to the information log.
Write-Host "PowerShell queue trigger function processed work item: $QueueItem"
Write-Host "Queue item insertion time: $($TriggerMetadata.InsertionTime)"

Push-OutputBinding -Name outputQueueItem -Value $QueueItem

function.json :

{
  "bindings": [
    {
      "name": "QueueItem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "ps-queue-items",
      "connection": "AzureWebJobsStorage"
    },
    {
      "type": "queue",
      "name": "outputQueueItem",
      "queueName": "outqueue",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
  ],
  "disabled": false
}

On my side, the message in ps-queue-items trigger the function and will output the same message to outqueue.

Have a look of this Offcial doc:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell#writing-output-data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM