Skip to content
Get Started for Free

Event Grid

Azure Event Grid is a fully managed event routing service for reactive and event-driven architectures. It helps publish events from producers to consumers through topics, domains, and event subscriptions. Event Grid is commonly used to decouple services and automate workflows based on event notifications. For more information, see What is Event Grid?.

LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Event Grid. The supported APIs are available on our API Coverage section, which provides information on the extent of Event Grid’s integration with LocalStack.

This guide is designed for users new to Event Grid and assumes basic knowledge of the Azure CLI and our azlocal wrapper script.

Launch LocalStack using your preferred method. For more information, see Introduction to LocalStack for Azure. Once the container is running, enable Azure CLI interception by running:

Terminal window
azlocal start-interception

This command points the az CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API. To revert this configuration, run:

Terminal window
azlocal stop-interception

This reconfigures the az CLI to send commands to the official Azure management REST API.

Create a resource group to contain your Event Grid resources:

Terminal window
az group create \
--name rg-eventgrid-demo \
--location westeurope
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-eventgrid-demo",
"location": "westeurope",
"name": "rg-eventgrid-demo",
"properties": {
"provisioningState": "Succeeded"
},
...
}

Create an Event Grid custom topic:

Terminal window
az eventgrid topic create \
--name egtopicdoc95 \
--resource-group rg-eventgrid-demo \
--location westeurope
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-eventgrid-demo/providers/Microsoft.EventGrid/topics/egtopicdoc95",
"name": "egtopicdoc95",
"location": "westeurope",
"endpoint": "https://egtopicdoc95.localhost.localstack.cloud:4566/api/events",
"provisioningState": "Succeeded",
...
}

Get and list topics:

Terminal window
az eventgrid topic show \
--name egtopicdoc95 \
--resource-group rg-eventgrid-demo
az eventgrid topic list \
--resource-group rg-eventgrid-demo
Output
{
"name": "egtopicdoc95",
"endpoint": "https://egtopicdoc95.localhost.localstack.cloud:4566/api/events",
"provisioningState": "Succeeded",
...
}
[
{
"name": "egtopicdoc95",
"endpoint": "https://egtopicdoc95.localhost.localstack.cloud:4566/api/events",
"provisioningState": "Succeeded",
...
}
]

List topic keys:

Terminal window
az eventgrid topic key list \
--name egtopicdoc95 \
--resource-group rg-eventgrid-demo

Regenerate the primary key and list keys again:

Terminal window
az eventgrid topic key regenerate \
--name egtopicdoc95 \
--resource-group rg-eventgrid-demo \
--key-name key1
az eventgrid topic key list \
--name egtopicdoc95 \
--resource-group rg-eventgrid-demo
Output
{
"key1": "...",
"key2": "..."
}
{
"key1": "...",
"key2": "..."
}

Get the topic resource ID and create an event subscription:

Terminal window
TOPIC_ID=$(az eventgrid topic show \
--name egtopicdoc95 \
--resource-group rg-eventgrid-demo \
--query id \
--output tsv)
az eventgrid event-subscription create \
--name egsubdoc95 \
--source-resource-id "$TOPIC_ID" \
--endpoint "https://webhook.localhost.localstack.cloud:4566/events"
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-eventgrid-demo/providers/Microsoft.EventGrid/topics/egtopicdoc95/providers/Microsoft.EventGrid/eventSubscriptions/egsubdoc95",
"name": "egtopicdoc95/providers/Microsoft.EventGrid/eventSubscriptions/egsubdoc95",
"provisioningState": "Succeeded",
...
}

Show the event subscription:

Terminal window
az eventgrid event-subscription show \
--name egsubdoc95 \
--source-resource-id "$TOPIC_ID"
Output
{
"name": "egtopicdoc95/providers/Microsoft.EventGrid/eventSubscriptions/egsubdoc95",
"provisioningState": "Succeeded",
...
}

Create an Event Grid domain:

Terminal window
az eventgrid domain create \
--name egdomaindoc95 \
--resource-group rg-eventgrid-demo \
--location westeurope
Output
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-eventgrid-demo/providers/Microsoft.EventGrid/domains/egdomaindoc95",
"name": "egdomaindoc95",
"location": "westeurope",
"endpoint": "https://egdomaindoc95.westeurope-1.eventgrid.azure.net/api/events",
"provisioningState": "Succeeded",
...
}

Get and list domains:

Terminal window
az eventgrid domain show \
--name egdomaindoc95 \
--resource-group rg-eventgrid-demo
az eventgrid domain list \
--resource-group rg-eventgrid-demo
Output
{
"name": "egdomaindoc95",
"endpoint": "https://egdomaindoc95.westeurope-1.eventgrid.azure.net/api/events",
"provisioningState": "Succeeded",
...
}
[
{
"name": "egdomaindoc95",
"endpoint": "https://egdomaindoc95.westeurope-1.eventgrid.azure.net/api/events",
"provisioningState": "Succeeded",
...
}
]
OperationImplemented
Page 1 of 0
Was this page helpful?