You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Az模块v12.5.0下PowerShell配置EventGrid死信端点问题

配置Azure Function事件订阅的死信存储容器

问题描述

使用Az模块v12.5.0创建FunctionApp的事件订阅时,现有代码可正常运行,但不清楚如何配置死信的存储账户容器(对应Azure门户中事件订阅的「死信」设置项)。现有代码如下:

$funcid = "/subscriptions/$funcSubID/resourceGroups/$func_rg/providers/Microsoft.Web/sites/$funcapp/functions/$func_name"
$func_evdo = New-AzEventGridAzureFunctionEventSubscriptionDestinationObject -ResourceId $funcid

New-AzEventGridSystemTopicEventSubscription -ResourceGroupName $resourceGroupName `
        -eventSubscriptionName $eventSubscriptionName `
        -systemTopicName $systemTopicName `
        -destination $func_evdo

解决方案

要配置死信存储容器,需先创建死信目标对象,再在创建事件订阅时指定该对象,具体步骤如下:

  1. 定义死信存储容器的资源ID
    格式示例:/subscriptions/<订阅ID>/resourceGroups/<资源组名>/providers/Microsoft.Storage/storageAccounts/<存储账户名>/blobServices/default/containers/<容器名>

  2. 创建死信目标对象
    使用New-AzEventGridStorageBlobDeadLetterDestinationObject命令生成死信目标:

    $deadLetterContainerId = "/subscriptions/$subID/resourceGroups/$storage_rg/providers/Microsoft.Storage/storageAccounts/$storageAccountName/blobServices/default/containers/$deadLetterContainerName"
    $deadLetterDest = New-AzEventGridStorageBlobDeadLetterDestinationObject -ResourceId $deadLetterContainerId
    
  3. 修改事件订阅创建命令
    在New-AzEventGridSystemTopicEventSubscription中添加-DeadLetterDestination参数,传入死信目标对象:

$funcid = "/subscriptions/$funcSubID/resourceGroups/$func_rg/providers/Microsoft.Web/sites/$funcapp/functions/$func_name"
$func_evdo = New-AzEventGridAzureFunctionEventSubscriptionDestinationObject -ResourceId $funcid

# 配置死信目标
$deadLetterContainerId = "/subscriptions/$subID/resourceGroups/$storage_rg/providers/Microsoft.Storage/storageAccounts/$storageAccountName/blobServices/default/containers/$deadLetterContainerName"
$deadLetterDest = New-AzEventGridStorageBlobDeadLetterDestinationObject -ResourceId $deadLetterContainerId

# 创建带死信配置的事件订阅
New-AzEventGridSystemTopicEventSubscription -ResourceGroupName $resourceGroupName `
        -eventSubscriptionName $eventSubscriptionName `
        -systemTopicName $systemTopicName `
        -destination $func_evdo `
        -DeadLetterDestination $deadLetterDest

注意事项

  • 需提前创建好目标存储账户和容器,且执行命令的账号需拥有该存储容器的写入权限
  • Az模块v12.5.0原生支持-DeadLetterDestination参数,无需升级模块即可使用

内容的提问来源于stack exchange,提问作者Frederic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 14:03:14