Create and monitor Media Services events with Event Grid using the Azure portal
Azure Event Grid is an eventing service for the cloud. This service uses event subscriptions to route event messages to subscribers. Media Services events contain all the information you need to respond to changes in your data. You can identify a Media Services event because the eventType property starts with "Microsoft.Media.". For more information, see Media Services event schemas.
In this article, you use the Azure portal to subscribe to events for your Azure Media Services account. Then, you trigger events to view the result. Typically, you send events to an endpoint that processes the event data and takes actions. In the article, we send events to a web app that collects and displays the messages.
When you're finished, you see that the event data has been sent to the web app.
- Have an active Azure subscription.
- Create a new Azure Media Services account, as described in this quickstart.
Create a message endpoint
Before subscribing to the events for the Media Services account, let's create the endpoint for the event message. Typically, the endpoint takes actions based on the event data. In this article, you deploy a pre-built web app that displays the event messages. The deployed solution includes an App Service plan, an App Service web app, and source code from GitHub.
Select Deploy to Azure to deploy the solution to your subscription. In the Azure portal, provide values for the parameters.
The deployment may take a few minutes to complete. After the deployment has succeeded, view your web app to make sure it's running. In a web browser, navigate to:
If you switch to the "Azure Event Grid Viewer" site, you see it has no events yet.
Enable Event Grid resource provider
If you haven't previously used Event Grid in your Azure subscription, you may need to register the Event Grid resource provider.
In the Azure portal:
- Select Subscriptions.
- Select the subscription you're using for Event Grid.
- Under Settings, select Resource providers.
- Find Microsoft.EventGrid.
- If not registered, select Register.
It may take a moment for the registration to finish. Select Refresh to update the status. When Status is Registered, you're ready to continue.
Subscribe to Media Services events
You subscribe to a topic to tell Event Grid which events you want to track, and where to send the events.
In the portal, select your Media Services account and select Events.
To send events to your viewer app, use a web hook for the endpoint.
The event subscription is prefilled with values for your Media Services account.
Select 'Web Hook' for the Endpoint Type.
In this topic, we leave the Subscribe to all event types checked. However, you can uncheck it and filter for specific event types.
Click on the Select an endpoint link.
For the web hook endpoint, provide the URL of your web app and add
api/updatesto the home page URL.
Press Confirm Selection.
Give your subscription a name.
View your web app again, and notice that a subscription validation event has been sent to it.
Event Grid sends the validation event so the endpoint can verify that it wants to receive event data. The endpoint has to set
validationCode. For more information, see Event Grid security and authentication. You can view the web app code to see how it validates the subscription.
Now, let's trigger events to see how Event Grid distributes the message to your endpoint.
Send an event to your endpoint
You can trigger events for the Media Services account by running an encoding job. You can follow this quickstart to encode a file and start sending events. If you subscribed to all events, you will see a screen similar to the following:
Select the eye icon to expand the event data. Do not refresh the page, if you want to view all the events.
Send feedback about: