Azure订阅上的Azure EventGrid-确定哪个标记已更改

时间:2019-06-03 09:50:23

标签: azure azure-eventgrid

我正在尝试为Azure订阅设置Azure EventGrid,以便在资源的某些标记发生更改时得到通知。

这是我创建EventGrid订阅的方式:

$includedEventTypes  = , 'Microsoft.Resources.ResourceWriteSuccess'
New-AzEventGridSubscription `
  -EventSubscriptionName mySubscriptionName `
  -ResourceGroupName myResourceGroup `
  -Endpoint myEndpoint `
  -IncludedEventType $includedEventTypes

现在,如果例如在Azure Web App上更改标签,则会收到以下事件:

{
  "subject": "/subscriptions/mySubId/resourceGroups/eventgrid/providers/Microsoft.Web/sites/wd-eventgrid-viewer",
  "eventType": "Microsoft.Resources.ResourceWriteSuccess",
  "eventTime": "2019-06-03T08:50:47.7469859Z",
  "id": "f193df79-6755-42c7-b663-91bc373a80e5",
  "data": {
    "authorization": {
      "scope": "/subscriptions/mySubId/resourceGroups/eventgrid/providers/Microsoft.Web/sites/wd-eventgrid-viewer",
      "action": "Microsoft.Web/sites/write",
      "evidence": {
        "role": "Subscription Admin"
      }
    },
    "claims": {
     ....
    },
    "correlationId": "9a1bb49f-9f39-4e98-918c-dfe0655b895a",
    "httpRequest": {
      "clientRequestId": "8bf9bfdb-6e65-4c55-84f2-3f4e05b340d0",
      "clientIpAddress": "......",
      "method": "PATCH",
      "url": "https://management.azure.com/subscriptions/mySubId/resourceGroups/eventgrid/providers/Microsoft.Web/sites/wd-eventgrid-viewer?api-version=2015-08-01"
    },
    "resourceProvider": "Microsoft.Web",
    "resourceUri": "/subscriptions/mySubId/resourceGroups/eventgrid/providers/Microsoft.Web/sites/wd-eventgrid-viewer",
    "operationName": "Microsoft.Web/sites/write",
    "status": "Succeeded",
    "subscriptionId": "mySubId",
    "tenantId": "...."
  },
  "dataVersion": "2",
  "metadataVersion": "1",
  "topic": "/subscriptions/mySubId"
}

很遗憾,我看不到标签已更改,也看不到哪个标签已更改。有什么方法可以接收资源的哪个标签已更改,还是在事件发生后我必须手动查询这些标签?

1 个答案:

答案 0 :(得分:2)

Azure Subscription Events会针对所记录的资源操作,删除或写入而发出。

仅向您提供用于获取更改的资源详细信息。

如您所想,您必须将这些详细信息与Resources API一起使用以获取标签。

更新get resource changes有一个新的API,可用于检测对资源所做的确切更改。 注意 ,该功能当前处于公开预览状态。