Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
本文介绍订阅 Azure 资源通知 - AKS 资源发布的事件所需的步骤。 有关这些事件的详细信息,请参阅 Azure 资源通知 - AKS 资源事件。
创建 AKS 资源系统主题
- Azure CLI
- Azure PowerShell
- Azure 门户
请将帐户设置为 Azure 订阅,然后在该订阅下创建系统主题。
az account set -s AZURESUBSCRIPTIONID使用
microsoft.resourcenotifications.AKSResources命令创建类型az eventgrid system-topic create的系统主题。az eventgrid system-topic create \ --name SYSTEMTOPICNAME \ --resource-group RESOURCEGROUPNAME \ --source /subscriptions/AZURESUBSCRIPTIONID \ --topic-type microsoft.resourcenotifications.AKSResources\ --location Global
订阅事件
- Azure CLI
- Azure PowerShell
- Azure 门户
使用 az eventgrid system-topic event-subscription create 命令为上述主题创建事件订阅。
以下示例命令为 FleetGateCreated 事件创建事件订阅。
az eventgrid system-topic event-subscription create \
--name stes-fleet-gates-sales-before-dev \
--resource-group $GROUP \
--system-topic-name stpc-aks-resource-notifications \
--included-event-types Microsoft.ResourceNotifications.AKSResources.FleetGateCreated \
--advanced-filter data.resourceInfo.properties.target.id StringContains "fleets/flt-mgr-approvals-01" \
--advanced-filter data.resourceInfo.properties.gateType StringIn Approval \
--advanced-filter data.resourceInfo.properties.state StringIn Pending \
--advanced-filter data.resourceInfo.properties.displayName StringContains "Check with sales teams" \
--advanced-filter data.resourceInfo.properties.target.updateRunProperties.timing StringIn Before \
--advanced-filter data.resourceInfo.properties.target.updateRunProperties.stage StringIn Dev \
--endpoint-type azurefunction \
--endpoint /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$GROUP/providers/Microsoft.Web/sites/fap-process-fleet-events/functions/fa-handle-pre-dev-events \
--max-delivery-attempts 10 \
--event-ttl 120
如果未指定 included-event-types,则默认包含所有事件类型。
若要从特定资源 筛选事件 ,请使用 --subject-begins-with 参数。 示例展示如何订阅指定资源组中资源的 FleetGateUpdated 事件。
az eventgrid system-topic event-subscription create \
--name EVENTSUBSCRIPTIONNAME \
--resource-group RESOURCEGROUPNAME \
--system-topic-name SYSTEMTOPICNAME \
--included-event-types Microsoft.ResourceNotifications.AKSResources.FleetGateUpdated \
--advanced-filter data.resourceInfo.properties.target.id StringContains "fleets/flt-mgr-approvals-01" \
--endpoint /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$GROUP/providers/Microsoft.Web/sites/fap-process-fleet-events/functions/fa-handle-pre-dev-events \
--endpoint-type azurefunction \
--subject-begins-with /subscriptions/AZURESUBSCRIPTIONID/resourceGroups/RESOURCEGROUPNAME/
删除事件订阅和系统主题
- Azure CLI
- Azure PowerShell
- Azure 门户
若要删除事件订阅,请使用 az eventgrid system-topic event-subscription delete 命令。 下面是一个示例:
az eventgrid system-topic event-subscription delete \
--name EVENTSUBSCRIPTIONNAME \
--resourcegroup RESOURCEGROUPNAME \
--system-topic-name SYSTEMTOPICNAME
若要删除系统主题,请使用 az eventgrid system-topic delete 命令。 下面是一个示例:
az eventgrid system-topic delete \
--name SYSTEMTOPICNAME \
--resource-group RESOURCEGROUPNAME
筛选示例
订阅 Gate 创建事件,以便接收待审批通知。
你可能希望将审批路由到不同的人员或团队。 为此,可以设置事件网格系统主题的多个订阅,并为每个订阅设置不同的筛选器。 例如,如果团队的群集位于单个更新运行组中,则可以筛选该组,并将终结点设置为其 Azure 函数,该函数运行更新后运行状况检查:
- Azure CLI
- Azure PowerShell
- Azure 门户
az eventgrid system-topic event-subscription create \
--name fleet-approvals-group-subscription \
--resource-group <resource-group> \
--system-topic-name system-topic-aksresources \
--included-event-types Microsoft.ResourceNotifications.AKSResources.FleetGateCreated \
--advanced-filter data.resourceInfo.properties.gateType StringIn Approval \
--advanced-filter data.resourceInfo.properties.state StringIn Pending \
--advanced-filter data.resourceInfo.properties.target.updateRunProperties.timing StringIn After \
--advanced-filter data.resourceInfo.properties.target.updateRunProperties.group StringIn teamName-group \
--endpoint-type azurefunction \
--endpoint /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.Web/sites/teamname/functions/health-check
还可以将 gate displayName 用作事件的筛选器:
az eventgrid system-topic event-subscription create \
--name fleet-approvals-group-subscription \
--resource-group <resource-group> \
--system-topic-name system-topic-aksresources \
--included-event-types Microsoft.ResourceNotifications.AKSResources.FleetGateCreated \
--advanced-filter data.resourceInfo.properties.gateType StringIn Approval \
--advanced-filter data.resourceInfo.properties.state StringIn Pending \
--advanced-filter data.resourceInfo.properties.displayName StringContains "Check with sales teams" \
--endpoint-type eventhub \
--endpoint /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.EventHub/namespaces/EVENTHUBNAMESPACE/eventhubs/EVENTHUBNAME
联系我们
如果对此功能有任何疑问或反馈,请毫不犹豫地通过此 stackoverflow 链接联系我们
为了更好地帮助你提供有关特定事件的特定反馈,请提供以下信息:
对于缺少的事件:
- 系统主题类型名称
- 执行操作时的近似时间戳(UTC)
- 生成通知的基准资源 ID
- 导航到 Azure 门户中的资源,然后选择最右侧的 JSON 视图。 资源 ID 是 JSON 视图页上的第一个字段。
- 预期事件类型
- 已执行的操作(例如:VM 已启动或停止、创建了存储帐户等)
- 遇到问题的说明(例如,VM 已启动且未生成 Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged 事件)
- 如果可能,请提供所执行操作的相关 ID。
对于延迟或包含意外内容的事件
- 系统主题类型名称
- 整个通知内容(不包括 data.resourceInfo.properties)
- 遇到问题的说明和受影响的字段值
请确保在共享此数据时未提供任何最终用户身份信息。
后续步骤
有关这些事件的详细信息,请参阅 Azure 资源通知 - AKS 资源事件。