0
votes

I am using event grid for my web api. The domain name of my api have changed and now I need to update all event grid subscriptions. It so happends that I have Azure CLI command to create each subscription, so the easiest way would be to delete all of them and create new ones. I have checked the docs but az eventgrid event-subscription delete command requires --name parameter which means that I need to execute this manually for each subscriptions. While this is not a huge problem it would require to maintain second command list for deleting. It would be much faster if I could simply say --all or something similar.

Maybe there is a solution to delete all event grid subscriptions without too much of o hassle?

My ideas so far:

  • Drop entire event grid topic and create new one (seems a bit excessive)
  • Apply some bash magic with az eventgrid event-subscription list
1
Is your source interest is a domain topic? If yes, see my comment to the @JimXu - Roman Kiss

1 Answers

1
votes

According to my test, we can use the following command to delete a list of subscriptions that are associated with Azure event gird topic in Azure Cloud Shell.

results=$(az eventgrid event-subscription list --source-resource-id /subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.EventGrid/domains/domain1/topics/topic1 --query "[].{Name:name}")


for row in $(echo "$results" | jq -r '.[]|"\(.Name)"')
do
  az eventgrid event-subscription delete --name $row --source-resource-id  /subscriptions/{SubID}/resourceGroups/{RG}/providers/Microsoft.EventGrid/domains/domain1/topics/topic1
done

enter image description here