powershell - 如何使用powershell获取azure函数中的出队计数

标签 powershell azure azure-functions azure-storage-queues

我已经使用 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/

相关文章:

azure - 如何对 Flaky Azure 函数应用程序行为进行故障排除?

powershell - Windows Service Recovery,无法执行PS脚本

powershell - Powershell if语句传递参数

azure - Terraform - Azure 标签格式化问题

javascript - 如何使用 javascript 在 azure 函数应用程序中使用服务总线主题 session

python - Azure Functions 可以用 Python 编写吗?

azure - 如何在 Azure Function 中定义 Azure Blob 存储触发器的路径

Powershell 用一个替换两个空行

powershell - 是否有等效于 [System.IO.Path]::GetFullPath($fileName); 的 powershell cmdlet?当 $fileName 不存在时?

spring-boot - 将证书从 Azure KeyVault 获取到 Kotlin/SpringBoot 中的 Keystore 以用于传出请求