处理事件网格事件Handling Event Grid events

媒体服务徽标 v3media services logo v3


媒体服务事件允许应用程序使用新式无服务器体系结构对不同事件(例如,作业状态更改事件)进行响应。Media Services events allow applications to react to different events (for example, the job state change event) using modern serverless architectures. 为此,它无需复杂的代码或高价低效的轮询服务。It does so without the need for complicated code or expensive and inefficient polling services. 相反,可以通过 Azure 事件网格向事件处理程序(如 Azure FunctionsAzure 逻辑应用),甚至是向自己的 Webhook 推送事件,且仅需为已使用的内容付费。Instead, events are pushed through Azure Event Grid to event handlers such as Azure Functions, Azure Logic Apps, or even to your own Webhook, and you only pay for what you use. 有关定价的详细信息,请参阅事件网格定价For information about pricing, see Event Grid pricing.

媒体服务事件的可用性与事件网格可用性相关联,当事件网格在其他地区可用时,媒体服务事件也同样可用。Availability for Media Services events is tied to Event Grid availability and will become available in other regions as Event Grid does.

媒体服务事件和架构Media Services events and schemas

事件网格使用事件订阅将事件消息路由到订阅方。Event grid 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. 可以识别媒体服务事件,因为 eventType 属性以“Microsoft.Media”开头。You can identify a Media Services event because the eventType property starts with "Microsoft.Media.".

有关详细信息,请参阅媒体服务事件架构For more information, see Media Services event schemas.

使用事件的做法Practices for consuming events

处理媒体服务事件的应用程序应遵循以下建议的做法:Applications that handle Media Services events should follow a few recommended practices:

  • 由于可将多个订阅配置为将事件路由至相同的事件处理程序,因此请勿假定事件来自特定的源,而是应检查消息的主题,确保它来自所期望的存储帐户。As multiple subscriptions can be configured to route events to the same event handler, it is important not to assume events are from a particular source, but to check the topic of the message to ensure that it comes from the storage account you are expecting.
  • 同样,检查 eventType 是否为准备处理的项,并且不假定所接收的全部事件都是期望的类型。Similarly, check that the eventType is one you are prepared to process, and do not assume that all events you receive will be the types you expect.
  • 忽略不了解的字段。Ignore fields you don't understand. 此做法有助于适应将来可能添加的新功能。This practice will help keep you resilient to new features that might be added in the future.
  • 使用“subject”前缀和后缀匹配项,将事件限制为特定事件。Use the "subject" prefix and suffix matches to limit events to a particular event.

备注

事件受事件网格服务级别协议 (SLA) 的约束。Events are subject to the Event Grid Service Level Agreement (SLA). 若要使用 API 获取事件通知,请参阅相关示例,了解如何通过 .NET SDKJava SDK 来使用事件。If you want to get event notifications using APIs, see examples on how to consume events, with .NET SDK or Java SDK.

后续步骤Next steps