充当事件网格源的 Azure 容器注册表

本文提供了容器注册表事件的属性和架构。 有关事件架构的简介,请参阅 Azure 事件网格事件架构

可用事件类型

Azure 容器注册表发出以下事件类型:

事件类型 说明
Microsoft.ContainerRegistry.ImagePushed 推送映像时引发。
Microsoft.ContainerRegistry.ImageDeleted 删除映像时引发。
Microsoft.ContainerRegistry.ChartPushed 推送 Helm 图表时引发。
Microsoft.ContainerRegistry.ChartDeleted 删除 Helm 图表时引发。

示例事件

以下示例显示了映像推送事件的架构:

[{
  "id": "831e1650-001e-001b-66ab-eeb76e069631",
  "topic": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ContainerRegistry/registries/<name>",
  "subject": "aci-helloworld:v1",
  "eventType": "Microsoft.ContainerRegistry.ImagePushed",
  "eventTime": "2018-04-25T21:39:47.6549614Z",
  "data": {
    "id": "31c51664-e5bd-416a-a5df-e5206bc47ed0",
    "timestamp": "2018-04-25T21:39:47.276585742Z",
    "action": "push",
    "location": "chinanorth",
    "target": {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 3023,
      "digest": "sha256:213bbc182920ab41e18edc2001e06abcca6735d87782d9cef68abd83941cf0e5",
      "length": 3023,
      "repository": "aci-helloworld",
      "tag": "v1"
    },
    "request": {
      "id": "7c66f28b-de19-40a4-821c-6f5f6c0003a4",
      "host": "demo.azurecr.io",
      "method": "PUT",
      "useragent": "docker/18.03.0-ce go/go1.9.4 git-commit/0520e24 os/windows arch/amd64 UpstreamClient(Docker-Client/18.03.0-ce \\\\(windows\\\\))"
    },
    "connectedRegistry": {
      "name": "edge1"
    }    
  },
  "dataVersion": "2.0",
  "metadataVersion": "1"
}]

映像删除事件的架构与此类似:

[{
  "id": "f06e3921-301f-42ec-b368-212f7d5354bd",
  "topic": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ContainerRegistry/registries/<name>",
  "subject": "aci-helloworld",
  "eventType": "Microsoft.ContainerRegistry.ImageDeleted",
  "eventTime": "2018-04-26T17:56:01.8211268Z",
  "data": {
    "id": "f06e3921-301f-42ec-b368-212f7d5354bd",
    "timestamp": "2018-04-26T17:56:00.996603117Z",
    "action": "delete",
    "location": "chinanorth",
    "target": {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "digest": "sha256:213bbc182920ab41e18edc2001e06abcca6735d87782d9cef68abd83941cf0e5",
      "repository": "aci-helloworld"
    },
    "request": {
      "id": "aeda5b99-4197-409f-b8a8-ff539edb7de2",
      "host": "demo.azurecr.io",
      "method": "DELETE",
      "useragent": "python-requests/2.18.4"
    },
    "connectedRegistry": {
      "name": "edge1"
    }    
  },
  "dataVersion": "2.0",
  "metadataVersion": "1"
}]

图表推送事件的架构类似于映像推送事件的架构,但不包括请求对象:

[{
  "id": "ea3a9c28-5b17-40f6-a500-3f02b6829277",
  "topic": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ContainerRegistry/registries/<name>",
  "subject": "mychart:1.0.0",
  "eventType": "Microsoft.ContainerRegistry.ChartPushed",
  "eventTime": "2019-03-12T22:16:31.5164086Z",
  "data": {
    "id":"ea3a9c28-5b17-40f6-a500-3f02b682927",
    "timestamp":"2019-03-12T22:16:31.0087496+00:00",
    "action":"chart_push",
    "location": "chinanorth",
    "target":{
      "mediaType":"application/vnd.acr.helm.chart",
      "size":25265,
      "digest":"sha256:7f060075264b5ba7c14c23672698152ae6a3ebac1c47916e4efe19cd624d5fab",
      "repository":"repo",
      "tag":"mychart-1.0.0.tgz",
      "name":"mychart",
      "version":"1.0.0"
    },
    "connectedRegistry": {
      "name": "edge1"
    }    
  },
  "dataVersion": "2.0",
  "metadataVersion": "1"
}]

图表删除事件的架构类似于映像删除事件的架构,但不包括请求对象:

[{
  "id": "39136b3a-1a7e-416f-a09e-5c85d5402fca",
  "topic": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.ContainerRegistry/registries/<name>",
  "subject": "mychart:1.0.0",
  "eventType": "Microsoft.ContainerRegistry.ChartDeleted",
  "eventTime": "019-03-12T22:42:08.7034064Z",
  "data": {
    "id":"ea3a9c28-5b17-40f6-a500-3f02b682927",
    "timestamp":"2019-03-12T22:42:08.3783775+00:00",
    "action":"chart_delete",
    "location": "chinanorth",
    "target":{
      "mediaType":"application/vnd.acr.helm.chart",
      "size":25265,
      "digest":"sha256:7f060075264b5ba7c14c23672698152ae6a3ebac1c47916e4efe19cd624d5fab",
      "repository":"repo",
      "tag":"mychart-1.0.0.tgz",
      "name":"mychart",
      "version":"1.0.0"
    },
    "connectedRegistry": {
      "name": "edge1"
    }    
  },
  "dataVersion": "2.0",
  "metadataVersion": "1"
}]

事件属性

事件具有以下顶级数据:

属性 类型 说明
topic string 事件源的完整资源路径。 此字段不可写入。 事件网格提供此值。
subject string 事件主题的发布者定义路径。
eventType string 此事件源的一个注册事件类型。
eventTime string 基于提供程序 UTC 时间的事件生成时间。
id string 事件的唯一标识符。
location string 活动的位置。
connectedRegistry object 如果事件是由连接的注册表生成的,则为连接的注册表信息。
data object Blob 存储事件数据。
dataVersion string 数据对象的架构版本。 发布者定义架构版本。
metadataVersion string 事件元数据的架构版本。 事件网格定义顶级属性的架构。 事件网格提供此值。

数据对象具有以下属性:

属性 类型 说明
id string 事件 ID。
timestamp string 发生事件的时间。
action string 包含所提供事件的操作。
target object 事件的目标。
request object 生成事件的请求。

目标对象具有以下属性:

属性 类型 说明
mediaType string 引用对象的 MIME 类型。
size integer 内容的字节数。 与 Length 字段相同。
digest string 内容摘要,由注册表 V2 HTTP API 规范定义。
length integer 内容的字节数。 与 Size 字段相同。
repository string 存储库名称。
tag string 标记名称。
name string 图表名称。
version string 图表版本。

请求对象具有以下属性:

属性 类型 说明
id string 启动事件的请求 ID。
addr string 启动事件的客户端连接的 IP 或主机名可能还有端口。 此值是标准 http 请求中的 RemoteAddr。
host string 注册表实例的外部可访问主机名,由传入请求中的 http 主机标头指定。
method string 生成事件的请求方法。
useragent string 请求的用户代理标头。

connectedRegistry 对象具有以下属性:

属性 类型 说明
name string 生成此事件的连接注册表的名称。

后续步骤