We are happy to announce the Public Preview of App Service’s integration with Azure Event Grid. Event Grid is a publish/subscribe messaging service that allows you to easily build event-based architectures. Event Grid is heavily integrated into Azure services, allowing you to react to events coming from your resources.
Follow the quickstart below to get started!
App Service now emits 13 events to Event Grid. These events span configuration changes, slot swaps, restarts, backups, and more. If you have an idea for an event type that you would like to see added, let us know on UserVoice.
|Triggered when a backup has started
|Triggered when a backup has completed
|Triggered when a backup has failed
|Triggered when a restoration from a backup has started
|Triggered when a restoration from a backup has completed
|Triggered when a restoration from a backup has failed
|Triggered when a slot swap has started
|Triggered when a slot swap has completed
|Triggered when a slot swap has failed
|Triggered when a slot swap with preview has started
|Triggered when a slot swap with preview has been cancelled
|Triggered when a site has been restarted, stopped, or the app settings have changed
|Triggered when an App Service Plan is updated
Event Grid is a flexible service that enables developers to architect cutting-edge, event-driven patterns. For example, you can resize images uploaded to Azure Storage, or get an email when your VM scales up.
This quickstart will walk through how to get started with a simple event handler, but we are excited to see what you can build with the newly integrated events from App Service.
Create a Function with an Event Grid trigger
First, create a new Azure Function with an Event Grid trigger. If you do not already have a Function App in your subscription, follow these instructions to create a new Function App. Once you have your Function App, browse to it in the Portal.
In the list of Functions, select the “+” to add a new Function.
In the following screen, filter the triggers by searching for “event grid”. Select “Azure Event Grid trigger” and enter a name for the Function. Finally, click “Create”.
Add the Function as an endpoint
Now that the Event Grid triggered Function is created, we will add it as a handler for events from our Azure Webapp. Navigate to one of your Azure Webapps in the Portal.
Select the “Events” button in the toolbar on the left side of the blade.
This will open a new blade where you can register event handlers. If you have used Event Grid before with other Azure services, this blade will look familiar.
Click “+ Event Subscription” at the top of the blade. In the following screen, enter a name for the event subscription and select “Azure Function” as the Endpoint Type. Next, click “Select an endpoint” and find your Event Grid triggered Function using the filters in the context menu. Finally, click “Create”.
You have now set up an Azure Function as an event handler for your Event Grid subscription. Whenever events are emitted from your web app, this Function will execute. Click back to the “Events” tab to see a timeline of your events.
This quickstart covered only a sliver of Event Grid’s capabilities. You can also use Logic Apps, Hybrid Connections, and web hooks as your event handlers. You can use these handlers to send yourself an email if a backup fails, send information to an on-premises resource, and much more!
If you have suggestions for events that App Service should emit, let us know on UserVoice.