Create and monitor Media Services events with Event Grid using the Azure portal
Warning
Azure Media Services will be retired June 30th, 2024. For more information, see the AMS Retirement Guide.
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.".
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.
Prerequisites
- 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 the Deploy to Azure link below 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:
https://<your-site-name>.azurewebsites.net
If you switch to the "Azure Event Grid Viewer" site, you see it has no events yet.
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 populated 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.
Select the Select an endpoint link. For the web hook endpoint, provide the URL of your web app and add
api/updates
to the home page URL.Select Confirm Selection.
Select Create.
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
validationResponse
tovalidationCode
. 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. Create a transform and a job in the portal to trigger events.
Media Services schema
For more information about all of the metrics available for Media Services, see Media Services event schemas.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for