azureazure-eventgridazure-cloud-shell

Updating EventGrid Topic to set DeadLettering destination using Azure CLI


I'm following the instructions here to add a --deadletter-endpoint to an existing EventGrid subscription.

The process is failing with error: Event subscription doesn't exist.

What am I missing?:

containername=eg-dead-letter-events //container where deadlettered events will be stored

topicid=$(az eventgrid system-topic show --name egtop-dev -g TEST_DEV --query id --output tsv) //name of eventgrid system topic

storageid=$(az storage account show --name stgdev --resource-group TEST_DEV --query id --output tsv) //name of storage account where deadlettered events will be stored

az eventgrid event-subscription update \
--name egsub-dev \ //name of Event Subscription here? also tried System Topic name, no go.
--source-resource-id $topicid \ //I cannot find a clear reference for what is supposed to go here
--deadletter-endpoint $storageid/blobServices/default/containers/$containername

Edit 1: Made some progress

az eventgrid event-subscription list --topic-type "Microsoft.Storage.StorageAccounts" --location southcentralus
az eventgrid event-subscription update --name egsub-dev --source-resource-id /subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.Storage/storageAccounts/storageAccountThatTriggersEventGrid/providers/Microsoft.EventGrid/eventSubscriptions/egsub-dev --deadletter-endpoint $storageid/blobServices/default/containers/$containername
No registered resource provider found for location 'southcentralus' and API version '2020-10-15-preview' for type 'storageAccounts'. The supported api-versions are '2021-04-01, 2021-02-01, 2021-01-01, 2020-08-01-preview, 2019-06-01, 2019-04-01, 2018-11-01, 2018-07-01, 2018-03-01-preview, 2018-02-01, 2017-10-01, 2017-06-01, 2016-12-01, 2016-05-01, 2016-01-01, 2015-06-15, 2015-05-01-preview'. The supported locations are 'eastus, eastus2, westus, westeurope, eastasia, southeastasia, japaneast, japanwest, northcentralus, southcentralus, centralus, northeurope, brazilsouth, australiaeast, australiasoutheast, southindia, centralindia, westindia, canadaeast, canadacentral, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, australiacentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, westus3, jioindiawest'.

Thoughts on this one?


Solution

  • Regarding the issue, please update the script as below

    sourceid=$(az eventgrid system-topic show --name egtop-dev -g TEST_DEV --query source --output tsv) 
    
    storageid=$(az storage account show --name stgdev --resource-group TEST_DEV --query id --output tsv)
    
    az eventgrid event-subscription update \
    --name egsub-dev \
    --source-resource-id $sourceid\
    --deadletter-endpoint $storageid/blobServices/default/containers/$containername