Azure App Service 做事件方格來源

本文提供 Azure App Service 事件的屬性和結構描述。 如需事件結構描述的簡介,請參閱 Azure Event Grid 事件結構描述。 其也會提供快速入門和教學課程的清單,以使用 Azure App Service 做為事件來源。

可用的事件類型

Azure App Service 會發出下列事件類型

事件類型 描述
Microsoft.Web/sites.BackupOperationStarted 在備份啟動時觸發
Microsoft.Web/sites.BackupOperationCompleted 在備份完成時觸發
Microsoft.Web/sites.BackupOperationFailed 在備份失敗時觸發
Microsoft.Web/sites.RestoreOperationStarted 在從備份還原啟動時觸發
Microsoft.Web/sites.RestoreOperationCompleted 在從備份還原完成時觸發
Microsoft.Web/sites.RestoreOperationFailed 在從備份還原失敗時觸發
Microsoft.Web/sites.SlotSwapStarted 在位置交換啟動時觸發
Microsoft.Web/sites.SlotSwapCompleted 在位置交換完成時觸發
Microsoft.Web/sites.SlotSwapFailed 在位置交換失敗時觸發
Microsoft.Web/sites.SlotSwapWithPreviewStarted 在使用預覽的位置交換啟動時觸發
Microsoft.Web/sites.SlotSwapWithPreviewCancelled 在使用預覽的位置交換取消時觸發
Microsoft.Web/sites.AppUpdated.Restarted 在網站重新啟動時觸發
Microsoft.Web/sites.AppUpdated.Stopped 在網站停止時觸發
Microsoft.Web/sites.AppUpdated.ChangedAppSettings 在網站的應用程式設定變更時觸發
Microsoft.Web/serverfarms.AppServicePlanUpdated 更新 App Service 方案時觸發

所有事件通用的屬性

觸發事件時,事件方格服務會將該事件的相關資料傳送至訂閱端點。 本節包含每個事件的資料外觀範例。 每個事件具有下列的最高層級資料:

屬性 類型​ 描述
topic string 事件來源的完整資源路徑。 此欄位無法寫入。 事件方格提供此值。
subject string 發行者定義事件主旨的路徑。
eventType string 此事件來源已註冊的事件類型之一。
eventTime string 事件產生的時間,以提供者的 UTC 時間為準。
id string 事件的唯一識別碼。
data object blob 儲存體帳戶。
dataVersion string 資料物件的結構描述版本。 發行者會定義結構描述版本。
metadataVersion string 事件中繼資料的結構描述版本。 「事件方格」會定義最上層屬性的結構描述。 事件方格提供此值。

範例事件

BackupOperationStarted、BackupOperationCompleted、BackupOperationFailed

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

資料物件包含下列屬性:

屬性 類型​ 描述
appEventTypeDetail object 應用程式上的動作詳細資料
action string 作業的動作類型
name string 具有此事件的網站名稱
clientRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的用戶端要求識別碼
correlationRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的相互關聯要求識別碼
requestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的要求識別碼
address string 這項作業的 HTTP 要求 URL
verb string 這項作業的 HTTP 動詞命令

RestoreOperationStarted、RestoreOperationCompleted、RestoreOperationFailed

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

資料物件包含下列屬性:

屬性 類型​ 描述
appEventTypeDetail object 應用程式上的動作詳細資料
action string 作業的動作類型
name string 具有此事件的網站名稱
clientRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的用戶端要求識別碼
correlationRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的相互關聯要求識別碼
requestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的要求識別碼
address string 這項作業的 HTTP 要求 URL
verb string 這項作業的 HTTP 動詞命令

SlotSwapStarted、SlotSwapCompleted、SlotSwapFailed

{
	"id": "7c5d6de5-eb70-4de2-b788-c52a544e68b8",
	"topic": "/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<site-name>",
	"subject": "/Microsoft.Web/sites/<site-name>",
	"eventType": "Microsoft.Web.SlotSwapStarted",
	"eventTime": "2020-01-28T18:26:51.7194887Z",
	"data": {
		"appEventTypeDetail": null,
		"name": "<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"
	},
	"dataVersion": "1",
	"metaDataVersion": "1"
}

資料物件包含下列屬性:

屬性 類型​ 描述
appEventTypeDetail object 應用程式上的動作詳細資料
action string 作業的動作類型
name string 具有此事件的網站名稱
clientRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的用戶端要求識別碼
correlationRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的相互關聯要求識別碼
requestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的要求識別碼
address string 這項作業的 HTTP 要求 URL
verb string 這項作業的 HTTP 動詞命令
sourceSlot string 交換的來源位置

SlotSwapWithPreviewStarted、SlotSwapWithPreviewCancelled

{
	"id": "7c5d6de5-eb70-4de2-b788-c52a544e68b8",
	"topic": "/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/sites/<site-name>",
	"subject": "/Microsoft.Web/sites/<site-name>",
	"eventType": "Microsoft.Web.SlotSwapWithPreviewStarted",
	"eventTime": "2020-01-28T18:26:51.7194887Z",
	"data": {
		"appEventTypeDetail": null,
		"name": "<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"
	},
	"dataVersion": "1",
	"metaDataVersion": "1"
}

資料物件包含下列屬性:

屬性 類型​ 描述
appEventTypeDetail object 應用程式上的動作詳細資料
action string 作業的動作類型
name string 具有此事件的網站名稱
clientRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的用戶端要求識別碼
correlationRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的相互關聯要求識別碼
requestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的要求識別碼
address string 這項作業的 HTTP 要求 URL
verb string 這項作業的 HTTP 動詞命令

AppUpdated.Restarted、AppUpdated.Stopped、AppUpdated.ChangedAppSettings

{
	"id": "b74ea56b-2a3f-4de5-a5d7-38e60c81cf23",
	"topic": "/subscriptions/<id>/resourceGroups/<group>/providers/Microsoft.Web/sites/<site-name>",
	"subject": "/Microsoft.Web/sites/<site-name>",
	"eventType": "Microsoft.Web.AppUpdated",
	"eventTime": "2020-01-28T18:22:30.2760952Z",
	"data": {
		"appEventTypeDetail": {
			"action": "Stopped"
		},
		"name": "<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"
	},
	"dataVersion": "1'",
	"metaDataVersion": "1"
}

資料物件具有下列屬性:

屬性 類型​ 描述
appEventTypeDetail object 應用程式上的動作詳細資料
action string 作業的動作類型
name string 具有此事件的網站名稱
clientRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的用戶端要求識別碼
correlationRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的相互關聯要求識別碼
requestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的要求識別碼
address string 這項作業的 HTTP 要求 URL
verb string 這項作業的 HTTP 動詞命令

Serverfarms.AppServicePlanUpdated

{
	"id": "56501672-9150-40e1-893a-18420c7fdbf7",
	"topic": "/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Web/serverfarms/<serverfarm-name>",
	"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"
	},
	"dataVersion": "1",
	"metaDataVersion": "1"
}

資料物件具有下列屬性:

屬性 類型​ 描述
appServicePlanEventTypeDetail object App Service 方案上的動作詳細資料
stampKind string App Service 方案所在的環境種類
action string App Service 方案上的動作類型
status string App Service 方案上的作業狀態
sku object App Service 方案的 SKU
name string App Service 方案的名稱
Tier string App Service 方案的層級
Size string App Service 方案的大小
Family string App Service 方案的系列
Capacity string App Service 方案的容量
action string 作業的動作類型
name string 具有此事件的網站名稱
clientRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的用戶端要求識別碼
correlationRequestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的相互關聯要求識別碼
requestId string 應用程式服務針對觸發此事件的網站 API 作業所產生的要求識別碼
address string 這項作業的 HTTP 要求 URL
verb string 這項作業的 HTTP 動詞命令

下一步