如何使用 PowerShell 获取 Azure 函数中的出队计数
how to get the dequeue count in azure functions with powershell
我已经使用 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
出队计数被推送为 'binding data'。 (每个触发器都有其特定于该触发器的唯一绑定数据。)在 C# 中,绑定数据可以直接绑定到参数,这就是上面示例有效的原因。在 Powershell 中,绑定数据通过 环境变量 传递。检查您的环境变量,您应该会看到这些。 (这里有一个很好的 HTTP 示例:https://blogs.technet.microsoft.com/stefan_stranger/2017/01/29/powershell-azure-functions-lessons-learned/)
我已经使用 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
出队计数被推送为 'binding data'。 (每个触发器都有其特定于该触发器的唯一绑定数据。)在 C# 中,绑定数据可以直接绑定到参数,这就是上面示例有效的原因。在 Powershell 中,绑定数据通过 环境变量 传递。检查您的环境变量,您应该会看到这些。 (这里有一个很好的 HTTP 示例:https://blogs.technet.microsoft.com/stefan_stranger/2017/01/29/powershell-azure-functions-lessons-learned/)