我已经使用 powershell 实现了 azure 存储队列触发的 azure 功能。 现在我正在寻找一种解决方案来读取队列项的出队计数以实现错误处理功能。 对于 C#,我从 MS 找到了一些解决方案,但没有找到 PS 的解决方案。
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Queue;
using System;
public static void Run(CloudQueueMessage myQueueItem,
DateTimeOffset expirationTime,
DateTimeOffset insertionTime,
DateTimeOffset nextVisibleTime,
string queueTrigger,
string id,
string popReceipt,
int dequeueCount,
TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem.AsString}\n" +
$"queueTrigger={queueTrigger}\n" +
$"expirationTime={expirationTime}\n" +
$"insertionTime={insertionTime}\n" +
$"nextVisibleTime={nextVisibleTime}\n" +
$"id={id}\n" +
$"popReceipt={popReceipt}\n" +
$"dequeueCount={dequeueCount}");
}
BR
最佳答案
出队计数作为“绑定(bind)数据”推送。 (每个触发器都有其特定于该触发器的唯一绑定(bind)数据。)在 C# 中,绑定(bind)数据可以直接绑定(bind)到参数,这就是上面示例起作用的原因。在 Powershell 中,绑定(bind)数据通过环境变量传递。检查你的环境变量,你应该看到这些。 (这里有一个关于 HTTP 的很好的例子:https://blogs.technet.microsoft.com/stefan_stranger/2017/01/29/powershell-azure-functions-lessons-learned/)
关于powershell - 如何使用powershell获取azure函数中的出队计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48786997/