Azure powershell函数如何将消息添加到存储帐户队列

标签 azure powershell azure-functions

我有基本的 Azure 功能,并且在集成中我已将触发器定义为 Azure 存储队列,将参数名称定义为queueItem。同样,我将输出设置为 Azure 存储队列,将参数名称设置为 outputQueueItem。当我将消息发送到输入队列但无法将消息发送到输出队列时,会触发函数。

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

$outputQueueItem = $QueueItem

我尝试过“$outputQueueItem.Add($QueueItem)”,但这些都不起作用。使用输出的正确方法是什么?

最佳答案

你可以按照我的方式尝试一下,在我这边效果很好:

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
}

在我这边,ps-queue-items 中的消息会触发该函数,并将相同的消息输出到 outqueue。

看看这个官方文档:

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

关于Azure powershell函数如何将消息添加到存储帐户队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61385632/

相关文章:

azure - 如何将外部程序集与 Microsoft Azure Function Apps 结合使用?

azure - 使用 Azure Functions 中的云应用设置

Azure模拟器存储安装错误

c# - 我如何或可以使用 Windows Azure 移动服务查询 WindowsPhone8 应用程序中的多个表?

powershell - 使用 powershell 手动将规模集中的虚拟机数量扩展为 5

SQL Azure 联合数据库备份

PowerShell - 批量更改文件编码为 UTF-8

windows - Windows 注册表中的应用程序显示名称部分匹配?

windows - WinRM 无法处理该请求。错误 0x80090311

azure - 使用 Azure 函数查询 SQL 表后在应用程序见解中生成警报