获取 Azure 应用服务中的资源事件Get resource events in Azure App Service

Azure 应用服务提供用于监视资源的状态和运行状况的内置工具。Azure App Service provides built-in tools to monitor the status and health of your resources. 资源事件可帮助你了解对基础 Web 应用资源所做的任何更改,并在必要时采取措施。Resource events help you understand any changes that were made to your underlying web app resources and take action as necessary. 事件示例包括:缩放实例、更新应用程序设置、重启 Web 应用等。Event examples include: scaling of instances, updates to application settings, restarting of the web app, and many more. 本文介绍如何查看 Azure 活动日志并启用事件网格,监视与应用服务 Web 应用相关的资源事件。In this article, you'll learn how to view Azure Activity Logs and enable Event Grid to monitor resource events related to your App Service web app.

备注

应用服务与事件网格的集成目前处于预览阶段。App Service integration with Event Grid is in preview. 查看公告以了解更多详细信息。View the announcement for more details.

查看 Azure 活动日志View Azure Activity Logs

Azure 活动日志包含对订阅中的资源执行的操作所发出的资源事件。Azure Activity Logs contain resource events emitted by operations taken on the resources in your subscription. Azure 门户和 Azure 资源管理器模板中的用户操作都会影响活动日志捕获的事件。Both the user actions in the Azure portal and Azure Resource Manager templates contribute to the events captured by the Activity log.

应用服务的 Azure 活动日志详细信息如下:Azure Activity Logs for App Service details such as:

  • 对资源执行了什么操作(例如:应用服务计划)what operations were taken on the resources (ex: App Service Plans)
  • 谁启动了该操作who started the operation
  • 操作何时发生when the operation occurred
  • 操作的状态the status of the operation
  • 有助于调查操作的属性值property values to help you research the operation

可以对 Azure 活动日志执行哪些操作?What can you do with Azure Activity Logs?

可以使用 Azure 门户、PowerShell、REST API 或 CLI 查询 Azure 活动日志。Azure Activity Logs can be queried using the Azure portal, PowerShell, REST API, or CLI. 可以将日志发送到存储帐户、事件中心和 Log Analytics。You can send the logs to a storage account, Event Hub, and Log Analytics. 还可以在 Power BI 中分析这些日志或创建警报以随时了解资源事件。You can also analyze them in Power BI or create alerts to stay updated on resource events.

查看和检索 Azure 活动日志事件。View and retrieve Azure Activity log events.

将活动日志传送到事件网格Ship Activity Logs to Event Grid

虽然活动日志是以用户为基础的,但我们推出了一个新的事件网格与应用服务的集成(预览版),可用于记录用户操作和自动化事件。While Activity logs are user-based, there's a new Event Grid integration with App Service (preview) that logs both user actions and automated events. 使用事件网格,可以配置处理程序以响应所述事件。With Event Grid, you can configure a handler to react to the said events. 例如,使用事件网格在每次向 Blob 存储容器添加新照片时,立即触发无服务器功能运行图像分析。For example, use Event Grid to instantly trigger a serverless function to run image analysis each time a new photo is added to a blob storage container.

或者,可使用具有逻辑应用的事件网格来处理任何位置的数据,而无需编写代码。Alternatively, you can use Event Grid with Logic Apps to process data anywhere, without writing code. 事件网格将数据源与事件处理程序连接。Event Grid connects data sources and event handlers. 例如,使用事件网格在每次向 Blob 存储容器添加新照片时,立即触发无服务器功能运行图像分析。For example, use Event Grid to instantly trigger a serverless function to run image analysis each time a new photo is added to a blob storage container.

查看 Azure 应用服务事件的属性和架构。View the properties and schema for Azure App Service Events.

后续步骤Next steps