az eventgrid event-subscription

Manage event subscriptions for an Event Grid topic or for an Azure resource.

Commands

az eventgrid event-subscription create Create a new event subscription for an Event Grid topic or for an Azure resource.
az eventgrid event-subscription delete Delete an event subscription.
az eventgrid event-subscription list List event subscriptions.
az eventgrid event-subscription show Get the details of an event subscription.
az eventgrid event-subscription update Update an event subscription.

az eventgrid event-subscription create

Create a new event subscription for an Event Grid topic or for an Azure resource.

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]

Examples

Create a new event subscription for an Event Grid topic, using default filters.

az eventgrid event-subscription create -g rg1 --topic-name topic1 --name es1 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code

Create a new event subscription for a subscription, using default filters.

az eventgrid event-subscription create --name es2 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code

Create a new event subscription for a resource group, using default filters.

az eventgrid event-subscription create -g rg1 --name es3 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code

Create a new event subscription for a storage account, using default filters.

az eventgrid event-subscription create --resource-id "/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/kalstest/providers/Microsoft.Storage/storageaccounts/kalsegblob" --name es3 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code

Create a new event subscription for a subscription, with a filter specifying a subject prefix.

az eventgrid event-subscription create --name es4 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code \
                            --subject-begins-with mysubject_prefix

Create a new event subscription for a resource group, with a filter specifying a subject suffix.

az eventgrid event-subscription create -g rg2 --name es5 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code \
                            --subject-ends-with mysubject_suffix

Create a new event subscription for a subscription, using default filters, and an EventHub as a destination.

az eventgrid event-subscription create --name es2 --endpoint-type eventhub \
                            --endpoint /subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1

Required Parameters

--endpoint

Endpoint where EventGrid should deliver events matching this event subscription. For webhook endpoint type, this should be the corresponding webhook URL. For eventhub endpoint type, this should be the Azure ResourceID of the event hub.

--name -n

Name of the new event subscription.

Optional Parameters

--endpoint-type
accepted values: eventhub, webhook
default value: webhook
--included-event-types

A space-separated list of event types. To subscribe to all event types, the string "All" should be specified.

--labels

A space-separated list of labels to associate with this event subscription.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-id

Fully qualified identifier of the Azure resource to which the event subscription needs to be created.

--subject-begins-with

An optional string to filter events for an event subscription based on a prefix. Wildcard characters are not supported.

--subject-case-sensitive

Specify to indicate whether the subject fields should be compared in a case sensitive manner. True if flag present.

accepted values: false, true
--subject-ends-with

An optional string to filter events for an event subscription based on a suffix. Wildcard characters are not supported.

--topic-name

Name of the Event Grid topic to which the event subscription needs to be created.

az eventgrid event-subscription delete

Delete an event subscription.

az eventgrid event-subscription delete --name
[--resource-group]
[--resource-id]
[--topic-name]

Examples

Delete an event subscription for an Event Grid topic.

az eventgrid event-subscription delete -g rg1 --topic-name topic1 --name es1

Delete an event subscription for a subscription.

az eventgrid event-subscription delete --name es2

Delete an event subscription for a resource group.

az eventgrid event-subscription delete -g rg1 --name es3

Delete an event subscription for a storage account.

az eventgrid event-subscription delete --resource-id "/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/kalstest/providers/microsoft.storage/storageaccounts/kalsegblob" --name es3

Required Parameters

--name -n

Name of the event subscription.

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-id

Fully qualified identifier of the Azure resource whose event subscription needs to be deleted.

--topic-name

Name of the Event Grid topic whose event subscription needs to be deleted.

az eventgrid event-subscription list

List event subscriptions.

az eventgrid event-subscription list [--location]
[--resource-group]
[--resource-id]
[--topic-name]
[--topic-type-name]

Examples

List all event subscriptions for an Event Grid topic.

az eventgrid event-subscription list -g rg1 --topic-name topic1

List all event subscriptions for a storage account.

az eventgrid event-subscription list --resource-id /subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/kalstest/providers/Microsoft.Storage/storageaccounts/kalsegblob

List all event subscriptions for a topic-type in a specific location (under the currently selected Azure subscription).

az eventgrid event-subscription list --topic-type Microsoft.Storage.StorageAccounts --location westus2

List all event subscriptions for a topic-type in a specific location under a specified resource group.

az eventgrid event-subscription list --topic-type Microsoft.Storage.StorageAccounts --location westus2 --resource-group kalstest

List all regional event subscriptions in a specific location (under the currently selected Azure subscription).

az eventgrid event-subscription list --location westus2

List all event subscriptions in a specific location under a specified resource group.

az eventgrid event-subscription list --location westus2 --resource-group kalstest

List all global event subscriptions (under the currently selected Azure subscription).

az eventgrid event-subscription list

List all global event subscriptions under the currently selected resource group.

az eventgrid event-subscription list --resource-group kalstest

Optional Parameters

--location -l

Location. You can configure the default location using az configure --defaults location=<location>.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-id

Fully qualified identifier of the Azure resource.

--topic-name

Name of the Event Grid topic.

--topic-type-name

Name of the topic type.

az eventgrid event-subscription show

Get the details of an event subscription.

az eventgrid event-subscription show --name
[--include-full-endpoint-url {false, true}]
[--resource-group]
[--resource-id]
[--topic-name]

Examples

Show the details of an event subscription for an Event Grid topic.

az eventgrid event-subscription show -g rg1 --topic-name topic1 --name es1

Show the details of an event subscription for a subscription.

az eventgrid event-subscription show --name es2

Show the details of an event subscription for a resource group.

az eventgrid event-subscription show -g rg1 --name es3

Show the details of an event subscription for a storage account.

az eventgrid event-subscription show --resource-id "/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/kalstest/providers/microsoft.storage/storageaccounts/kalsegblob" --name es3

Required Parameters

--name -n

Name of the event subscription.

Optional Parameters

--include-full-endpoint-url

Specify to indicate whether the full endpoint URL should be returned. True if flag present.

accepted values: false, true
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-id

Fully qualified identifier of the Azure resource.

--topic-name

Name of the Event Grid topic.

az eventgrid event-subscription update

Update an event subscription.

az eventgrid event-subscription update --name
[--add]
[--endpoint]
[--endpoint-type {eventhub, webhook}]
[--included-event-types]
[--labels]
[--remove]
[--resource-group]
[--resource-id]
[--set]
[--subject-begins-with]
[--subject-ends-with]
[--topic-name]

Examples

Update an event subscription for an Event Grid topic to specify a new endpoint.

az eventgrid event-subscription update -g rg1 --topic-name topic1 --name es1 \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code

Update an event subscription for a subscription to specify a new subject-ends-with filter.

az eventgrid event-subscription update --name es2 --subject-ends-with .jpg

Update an event subscription for a resource group to specify a new endpoint and a new subject-ends-with filter.

az eventgrid event-subscription update -g rg1 --name es3  --subject-ends-with .png \
                            --endpoint https://contoso.azurewebsites.net/api/f1?code=code

Update an event subscription for a storage account to specify a new list of included event types.

az eventgrid event-subscription update --resource-id "/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/kalstest/providers/microsoft.storage/storageaccounts/kalsegblob" --name es3 \
                            --included-event-types Microsoft.Storage.BlobCreated Microsoft.Storage.BlobDeleted

Required Parameters

--name -n

Name of the event subscription.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--endpoint

Endpoint where EventGrid should deliver events matching this event subscription. For webhook endpoint type, this should be the corresponding webhook URL. For eventhub endpoint type, this should be the Azure ResourceID of the event hub.

--endpoint-type
accepted values: eventhub, webhook
default value: webhook
--included-event-types

A space-separated list of event types. To subscribe to all event types, the string "All" should be specified.

--labels

A space-separated list of labels to associate with this event subscription.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-id

Fully qualified identifier of the Azure resource.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--subject-begins-with

An optional string to filter events for an event subscription based on a prefix. Wildcard characters are not supported.

--subject-ends-with

An optional string to filter events for an event subscription based on a suffix. Wildcard characters are not supported.

--topic-name

Name of the Event Grid topic.