0

I am trying to create a subscription for my Azure EventGrid Topic using the Azure CLI command as below -

az eventgrid topic event-subscription create -g myresname --topic-name mytopicname --name mysubscriptionname --endpoint https://xyz.azurewebsites.net/api/mywebhookdetails

I am getting this error in the BASH shell in Azure CLI

az eventgrid topic: error: argument _subcommand: invalid choice: event-subscription

What is the reason and how to resolve this?

GilliVilla
  • 4,998
  • 11
  • 55
  • 96

2 Answers2

1

There was a CLI update last month which introduced some changes in this syntax. Please use the following command (the only difference is you don't need to specify the "topic" after eventgrid):

az eventgrid event-subscription create -g myresname --topic-name mytopicname --name mysubscriptionname --endpoint https://xyz.azurewebsites.net/api/mywebhookdetails

1

This is because the command you used az eventgrid topic event-subscription create is not for the latest version Azure CLI.

You can use this command in Azure CLI:

az eventgrid event-subscription create --endpoint
                                       --name
                                       [--endpoint-type {eventhub, webhook}]
                                       [--included-event-types]
                                       [--labels]
                                       [--resource-group]
                                       [--resource-id]
                                       [--subject-begins-with]
                                       [--subject-case-sensitive {false, true}]
                                       [--subject-ends-with]
                                       [--topic-name]

Example:

az eventgrid event-subscription create -g myresname --topic-name mytopicname --name mysubscriptionname --endpoint https://xyz.azurewebsites.net/api/mywebhookdetails

You can see more details in this document.

Wayne Yang
  • 9,016
  • 2
  • 20
  • 40