将 Azure 应用服务用作事件网格源Azure App Service as an Event Grid source

本文提供了 Azure 应用服务事件的属性和架构。This article provides the properties and schema for Azure App Service events. 有关事件架构的简介,请参阅 Azure 事件网格事件架构For an introduction to event schemas, see Azure Event Grid event schema. 本文还提供了有关将 Azure 应用服务用作事件源的快速入门和教程列表。It also gives you a list of quick starts and tutorials to use Azure App Service as an event source.

事件网格事件架构Event Grid event schema

可用事件类型Available event types

Azure 应用服务发出以下事件类型Azure App Service emits the following event types

事件类型Event Type 说明Description
Microsoft.Web/sites.BackupOperationStartedMicrosoft.Web/sites.BackupOperationStarted 备份开始时触发Triggered when a backup has started
Microsoft.Web/sites.BackupOperationCompletedMicrosoft.Web/sites.BackupOperationCompleted 备份完成时触发Triggered when a backup has completed
Microsoft.Web/sites.BackupOperationFailedMicrosoft.Web/sites.BackupOperationFailed 备份失败时触发Triggered when a backup has failed
Microsoft.Web/sites.RestoreOperationStartedMicrosoft.Web/sites.RestoreOperationStarted 从备份还原开始时触发Triggered when a restoration from a backup has started
Microsoft.Web/sites.RestoreOperationCompletedMicrosoft.Web/sites.RestoreOperationCompleted 从备份还原完成时触发Triggered when a restoration from a backup has completed
Microsoft.Web/sites.RestoreOperationFailedMicrosoft.Web/sites.RestoreOperationFailed 从备份还原失败时触发Triggered when a restoration from a backup has failed
Microsoft.Web/sites.SlotSwapStartedMicrosoft.Web/sites.SlotSwapStarted 槽交换开始时触发Triggered when a slot swap has started
Microsoft.Web/sites.SlotSwapCompletedMicrosoft.Web/sites.SlotSwapCompleted 槽交换完成时触发Triggered when a slot swap has completed
Microsoft.Web/sites.SlotSwapFailedMicrosoft.Web/sites.SlotSwapFailed 槽交换失败时触发Triggered when a slot swap has failed
Microsoft.Web/sites.SlotSwapWithPreviewStartedMicrosoft.Web/sites.SlotSwapWithPreviewStarted 启动带预览的槽交换时触发Triggered when a slot swap with preview has started
Microsoft.Web/sites.SlotSwapWithPreviewCancelledMicrosoft.Web/sites.SlotSwapWithPreviewCancelled 取消带预览的槽交换时触发Triggered when a slot swap with preview has been canceled
Microsoft.Web/sites.AppUpdated.RestartedMicrosoft.Web/sites.AppUpdated.Restarted 站点重启时触发Triggered when a site has been restarted
Microsoft.Web/sites.AppUpdated.StoppedMicrosoft.Web/sites.AppUpdated.Stopped 站点停止时触发Triggered when a site has been stopped
Microsoft.Web/sites.AppUpdated.ChangedAppSettingsMicrosoft.Web/sites.AppUpdated.ChangedAppSettings 站点的应用设置更改时触发Triggered when a site’s app settings have changed
Microsoft.Web/serverfarms.AppServicePlanUpdatedMicrosoft.Web/serverfarms.AppServicePlanUpdated 应用服务计划更新时触发Triggered when an App Service Plan is updated

事件响应的内容The contents of an event response

触发某个事件后,事件网格服务会将有关该事件的数据发送到订阅终结点。When an event is triggered, the Event Grid service sends data about that event to subscribing endpoint. 本部分包含一个示例,介绍每个事件的数据外观。This section contains an example of what that data would look like for each event. 每个事件具有以下顶级数据:Each event has the following top-level data:

属性Property 类型Type 说明Description
主题topic stringstring 事件源的完整资源路径。Full resource path to the event source. 此字段不可写入。This field is not writeable. 事件网格提供此值。Event Grid provides this value.
subjectsubject stringstring 事件主题的发布者定义路径。Publisher-defined path to the event subject.
eventTypeeventType stringstring 此事件源的已注册事件类型之一。One of the registered event types for this event source.
EventTimeeventTime stringstring 事件的生成时间,基于提供程序的 UTC 时间。The time the event is generated based on the provider's UTC time.
idid stringstring 事件的唯一标识符。Unique identifier for the event.
数据data objectobject Blob 存储事件数据。Blob storage event data.
dataVersiondataVersion stringstring 数据对象的架构版本。The schema version of the data object. 发布者定义架构版本。The publisher defines the schema version.
metadataVersionmetadataVersion stringstring 事件元数据的架构版本。The schema version of the event metadata. 事件网格定义顶级属性的架构。Event Grid defines the schema of the top-level properties. 事件网格提供此值。Event Grid provides this value.

BackupOperationStarted、BackupOperationCompleted、BackupOperationFailedBackupOperationStarted, BackupOperationCompleted, BackupOperationFailed

{
    id:'7c5d6de5-eb70-4de2-b788-c52a544e68b8',
    subject:'/Microsoft.Web/sites/<site-name>',
    eventType:'Microsoft.Web.BackupOperationStarted',
    eventTime:'2020-01-28T18:26:51.7194887Z',
    data: {
        "appEventTypeDetail": { "action": "Started" },
        "siteName": "<site-name>",
        "clientRequestId": "None",
        "correlationRequestId": "None",
        "requestId": "292f499d-04ee-4066-994d-c2df57b99198",
        "address": "None",
        "verb": "None"
    }
    topic:'/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<site-name>',
    dataVersion:'1',
    metaDataVersion:'1'
}

数据对象包含以下属性:The data object contains the following properties:

属性Property 类型Type 说明Description
appEventTypeDetailappEventTypeDetail objectobject 对应用执行的操作的详细信息Detail of action on the app
actionaction stringstring 操作的操作类型Type of action of the operation
namename stringstring 发生此事件的网站的名称name of the web site that had this event
ClientRequestIdclientRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的客户端请求 IDThe client request id generated by the app service for the site API operation that triggered this event
correlationRequestIdcorrelationRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的关联请求 IDThe correlation request id generated by the app service for the site API operation that triggered this event
requestIdrequestId stringstring 应用服务为触发此事件的站点 API 操作生成的请求 IDThe request id generated by the app service for the site API operation that triggered this event
addressaddress stringstring 此操作的 HTTP 请求 URLHTTP request URL of this operation
谓词verb stringstring 此操作的 HTTP 谓词HTTP verb of this operation

RestoreOperationStarted、RestoreOperationCompleted、RestoreOperationFailedRestoreOperationStarted, RestoreOperationCompleted, RestoreOperationFailed

{
    id: '7c5d6de5-eb70-4de2-b788-c52a544e68b8',
    subject: '/Microsoft.Web/sites/<site-name>',
    eventType: 'Microsoft.Web.RestoreOperationStarted',
    eventTime: '2020-01-28T18:26:51.7194887Z',
    data: {
        appEventTypeDetail: { 
            action: "Started" 
        },
        siteName: "<site-name>",
        clientRequestId: "None",
        correlationRequestId: "None",
        requestId: "292f499d-04ee-4066-994d-c2df57b99198",
        address: "None",
        verb: "POST"
    }
    topic: '/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<site-name>',
    dataVersion: '1',
    metaDataVersion: '1'
}

数据对象包含以下属性:The data object contains the following properties:

属性Property 类型Type 说明Description
appEventTypeDetailappEventTypeDetail objectobject 对应用执行的操作的详细信息Detail of action on the app
actionaction stringstring 操作的操作类型Type of action of the operation
namename stringstring 发生此事件的网站的名称name of the web site that had this event
ClientRequestIdclientRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的客户端请求 IDThe client request id generated by the app service for the site API operation that triggered this event
correlationRequestIdcorrelationRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的关联请求 IDThe correlation request id generated by the app service for the site API operation that triggered this event
requestIdrequestId stringstring 应用服务为触发此事件的站点 API 操作生成的请求 IDThe request id generated by the app service for the site API operation that triggered this event
addressaddress stringstring 此操作的 HTTP 请求 URLHTTP request URL of this operation
谓词verb stringstring 此操作的 HTTP 谓词HTTP verb of this operation

SlotSwapStarted、SlotSwapCompleted、SlotSwapFailedSlotSwapStarted, SlotSwapCompleted, SlotSwapFailed

{
    id: '7c5d6de5-eb70-4de2-b788-c52a544e68b8',
    subject: '/Microsoft.Web/sites/<site-name>',
    eventType: 'Microsoft.Web.SlotSwapStarted',
    eventTime: '2020-01-28T18:26:51.7194887Z',
    data: {
        appEventTypeDetail: null,
        siteName: '<site-name>',
        clientRequestId: '922f4841-20d9-4dd6-8c5b-23f0d85e5592',
        correlationRequestId: '9ac46505-2b8a-4e06-834c-05ffbe2e8c3a',
        requestId: '765117aa-eaf8-4bd2-a644-1dbf69c7b0fd',
        address: '/websystems/WebSites/web/subscriptions/<id>/webspaces/<webspace>/sites/<site-name>/slots?Command=SWAP&targetSlot=production',
        verb: 'POST'
        sourceSlot: "staging",
        targetSlot: "production"
    },
    topic: '/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<site-name>',
    dataVersion: '1',
    metaDataVersion: '1'
}

数据对象包含以下属性:The data object contains the following properties:

属性Property 类型Type 说明Description
appEventTypeDetailappEventTypeDetail objectobject 对应用执行的操作的详细信息Detail of action on the app
actionaction stringstring 操作的操作类型Type of action of the operation
namename stringstring 发生此事件的网站的名称name of the web site that had this event
ClientRequestIdclientRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的客户端请求 IDThe client request id generated by the app service for the site API operation that triggered this event
correlationRequestIdcorrelationRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的关联请求 IDThe correlation request id generated by the app service for the site API operation that triggered this event
requestIdrequestId stringstring 应用服务为触发此事件的站点 API 操作生成的请求 IDThe request id generated by the app service for the site API operation that triggered this event
addressaddress stringstring 此操作的 HTTP 请求 URLHTTP request URL of this operation
谓词verb stringstring 此操作的 HTTP 谓词HTTP verb of this operation
sourceSlotsourceSlot stringstring 用于交换的源槽The source slot of the swap

SlotSwapWithPreviewStarted、SlotSwapWithPreviewCancelledSlotSwapWithPreviewStarted, SlotSwapWithPreviewCancelled

{
    id: '7c5d6de5-eb70-4de2-b788-c52a544e68b8',
    subject: '/Microsoft.Web/sites/<site-name>',
    eventType: 'Microsoft.Web.SlotSwapWithPreviewStarted',
    eventTime: '2020-01-28T18:26:51.7194887Z',
    data: {
        appEventTypeDetail: null,
        siteName: '<site-name>',
        clientRequestId: '922f4841-20d9-4dd6-8c5b-23f0d85e5592',
        correlationRequestId: '9ac46505-2b8a-4e06-834c-05ffbe2e8c3a',
        requestId: '765117aa-eaf8-4bd2-a644-1dbf69c7b0fd',
        address: '/websystems/WebSites/web/subscriptions/<id>/webspaces/<webspace>/sites/<site-name>/slots?Command=SWAP&targetSlot=production',
        verb: 'POST'
        sourceSlot: "staging",
        targetSlot: "production"
    },
    topic: '/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<site-name>',
    dataVersion: '1',
    metaDataVersion: '1'
}

数据对象包含以下属性:The data object contains the following properties:

属性Property 类型Type 说明Description
appEventTypeDetailappEventTypeDetail objectobject 对应用执行的操作的详细信息Detail of action on the app
actionaction stringstring 操作的操作类型Type of action of the operation
namename stringstring 发生此事件的网站的名称name of the web site that had this event
ClientRequestIdclientRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的客户端请求 IDThe client request id generated by the app service for the site API operation that triggered this event
correlationRequestIdcorrelationRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的关联请求 IDThe correlation request id generated by the app service for the site API operation that triggered this event
requestIdrequestId stringstring 应用服务为触发此事件的站点 API 操作生成的请求 IDThe request id generated by the app service for the site API operation that triggered this event
addressaddress stringstring 此操作的 HTTP 请求 URLHTTP request URL of this operation
谓词verb stringstring 此操作的 HTTP 谓词HTTP verb of this operation

AppUpdated.Restarted、AppUpdated.Stopped、AppUpdated.ChangedAppSettingsAppUpdated.Restarted, AppUpdated.Stopped, AppUpdated.ChangedAppSettings

{
    id: 'b74ea56b-2a3f-4de5-a5d7-38e60c81cf23',
    subject: '/Microsoft.Web/sites/<site-name>',
    eventType: 'Microsoft.Web.AppUpdated',
    eventTime: '2020-01-28T18:22:30.2760952Z',
    data: {
        appEventTypeDetail: {
            action: 'Stopped'
        },
        siteName: '<site-name>',
        clientRequestId: '64a5e0aa-7cee-4ff1-9093-b9197b820014',
        correlationRequestId: '25bb36a5-8f6c-4f04-b615-e9a0ee045756',
        requestId: 'f2e8eb3f-b190-42de-b99e-6acefe587374',
        address: '/websystems/WebSites/web/subscriptions/<id>/webspaces/<webspace>/sites/<site-name>/stop',
        verb: 'POST'
    },
    topic: '/subscriptions/<id>/resourceGroups/<group>/providers/Microsoft.Web/sites/<site-name>',
    dataVersion: '1',
    metaDataVersion: '1'
}

数据对象具有以下属性:The data object has the following properties:

属性Property 类型Type 说明Description
appEventTypeDetailappEventTypeDetail objectobject 对应用执行的操作的详细信息Detail of action on the app
actionaction stringstring 操作的操作类型Type of action of the operation
namename stringstring 发生此事件的网站的名称name of the web site that had this event
ClientRequestIdclientRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的客户端请求 IDThe client request id generated by the app service for the site API operation that triggered this event
correlationRequestIdcorrelationRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的关联请求 IDThe correlation request id generated by the app service for the site API operation that triggered this event
requestIdrequestId stringstring 应用服务为触发此事件的站点 API 操作生成的请求 IDThe request id generated by the app service for the site API operation that triggered this event
addressaddress stringstring 此操作的 HTTP 请求 URLHTTP request URL of this operation
谓词verb stringstring 此操作的 HTTP 谓词HTTP verb of this operation

Serverfarms.AppServicePlanUpdatedServerfarms.AppServicePlanUpdated

{
   id: "56501672-9150-40e1-893a-18420c7fdbf7",
   subject: "/Microsoft.Web/serverfarms/<plan-name>",
   eventType: "Microsoft.Web.AppServicePlanUpdated",
   eventTime: "2020-01-28T18:22:23.5516004Z",
   data: {
        serverFarmEventTypeDetail: {
            stampKind: "Public",
            action: "Updated",
            status: "Started"
        },
        serverFarmId: "0",
        sku: {
            name: "P1v2",
            tier: "PremiumV2",
            size: "P1v2",
            family: "Pv2",
            capacity: 1
        },
        clientRequestId: "8f880321-a991-45c7-b743-6ff63fe4c004",
        correlationRequestId: "1995c3be-ba7f-4ccf-94af-516df637ec8a",
        requestId: "b973a8e6-6949-4783-b44c-ac778be831bb",
        address: "/websystems/WebSites/serverfarms/subscriptions/<id>/webspaces/<webspace-id>/serverfarms/<plan-name>/async",
        verb: "PUT"
   },
   topic: "/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/serverfarms/<serverfarm-name>",
   dataVersion: "1",
   metaDataVersion: "1"
}

数据对象具有以下属性:The data object has the following properties:

属性Property 类型Type 说明Description
appServicePlanEventTypeDetailappServicePlanEventTypeDetail objectobject 对应用服务计划执行的操作的详细信息Detail of action on the app service plan
stampKindstampKind stringstring 应用服务计划所在环境的种类Kind of environment where app service plan is
actionaction stringstring 对应用服务计划执行的操作的类型Type of action on the app service plan
状态status stringstring 对应用服务计划执行的操作的状态Status of the operation on the app service plan
skusku objectobject 应用服务计划的 SKUsku of the app service plan
namename stringstring 应用服务计划的名称name of the app service plan
Tier stringstring 应用服务计划的层tier of the app service plan
大小Size stringstring 应用服务计划的大小size of the app service plan
系列Family stringstring 应用服务计划的系列family of app service plan
容量Capacity stringstring 应用服务计划的容量capacity of app service plan
actionaction stringstring 操作的操作类型Type of action of the operation
namename stringstring 发生此事件的网站的名称name of the web site that had this event
ClientRequestIdclientRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的客户端请求 IDThe client request id generated by the app service for the site API operation that triggered this event
correlationRequestIdcorrelationRequestId stringstring 应用服务为触发此事件的站点 API 操作生成的关联请求 IDThe correlation request id generated by the app service for the site API operation that triggered this event
requestIdrequestId stringstring 应用服务为触发此事件的站点 API 操作生成的请求 IDThe request id generated by the app service for the site API operation that triggered this event
addressaddress stringstring 此操作的 HTTP 请求 URLHTTP request URL of this operation
谓词verb stringstring 此操作的 HTTP 谓词HTTP verb of this operation