你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
使用 Azure 事件网格 ,可以使用基于事件的体系结构轻松生成应用程序。 此解决方案包含来自 Azure 服务对事件的内置支持,如存储 blob 和资源组。 事件网格还使用自定义主题支持自己的事件。
有关使用事件网格的详细信息,请参阅使用 Azure 事件网格创建和路由自定义事件。
若要了解如何使用事件网格提升工作负荷的作卓越性,请参阅 事件网格主题和事件网格域的诊断日志。
以下部分特定于 Azure 事件网格和卓越运营:
- 设计注意事项
- 配置清单
- 建议的配置选项
- 源项目
设计注意事项
Azure 事件网格提供运行时间 SLA。 有关详细信息,请参阅 事件网格的 SLA。
清单
您是否在配置 Azure 事件网格时考虑了卓越运营?
- 监视事件网格以查看失败的事件传递。
- 使用批量事件。
- 事件批处理的大小不能超过
1MB
。 - 在负载测试期间配置和优化批处理大小选择。
- 确保只有在传递到包含自定义代码的终结点时,事件网格消息才会与
HTTP
200-204
响应一起被接受。 - 监视事件网格以查看失败的事件发布。
配置建议
在配置 Azure 事件网格时,请考虑以下建议来优化卓越运营:
建议 | 说明 |
---|---|
监视事件网格以查看失败的事件传递。 | 每次无法将消息传送到事件处理程序(超时或非200-204 HTTP 状态代码)时,指标Delivery Failed 都会增加。 如果事件不能丢失,请设置死信队列 (DLQ) 存储帐户。 DLQ 帐户用于放置在最大重试次数后无法传递的事件。 (可选)通过在 DLQ 存储帐户上实现通知系统,例如,通过事件网格处理 新文件 事件。 |
在高吞吐量方案中使用批处理事件。 | 该服务会将包含多个事件的数组传递到 json 订阅服务器,而不是一个包含一个事件的数组。 使用的应用程序必须能够处理这些数组。 |
事件批处理的大小不能超过 1MB 。 |
如果消息有效负载很大,则只有一条或几条消息适合批处理。 使用服务需要处理更多事件批处理。 如果事件具有大型有效负载,请考虑将其存储在其他位置,例如在 Blob 存储中,并在事件中传递引用。 通过 CloudEvents 架构与第三方服务集成时,不建议超过 64KB 事件。 |
在负载测试期间配置和优化批处理大小选择。 | 批大小选择取决于有效负载大小和消息量。 |
监视事件网格以查看失败的事件发布。 | 该 Unmatched 指标将显示已发布但与任何订阅不匹配的消息。 根据应用程序体系结构,后者可能是有意的。 |
源项目
若要确定所有可用事件网格主题的 输入架构 类型,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/topics'
| project name, resourceGroup, ___location, subscriptionId, properties['inputSchema']
要检索事件网格域中现有专用终结点的资源 ID,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/domains' and notnull(properties['privateEndpointConnections'])
| mvexpand properties['privateEndpointConnections']
| project-rename privateEndpointConnections = properties_privateEndpointConnections
| project name, resourceGroup, ___location, subscriptionId, privateEndpointConnections['properties']['privateEndpoint']['id']
若要识别所有可用事件网格域的公共 网络访问 状态,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/domains'
| project name, resourceGroup, ___location, subscriptionId, properties['publicNetworkAccess']
若要识别所有公共事件网格域的 防火墙规则 ,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/domains' and properties['publicNetworkAccess'] == 'Enabled'
| project name, resourceGroup, ___location, subscriptionId, properties['inboundIpRules']
若要识别所有公共事件网格主题的 防火墙规则 ,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/topics' and properties['publicNetworkAccess'] == 'Enabled'
| project name, resourceGroup, ___location, subscriptionId, properties['inboundIpRules']
要检索事件网格主题中现有专用终结点的资源 ID,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/topics' and notnull(properties['privateEndpointConnections'])
| mvexpand properties['privateEndpointConnections']
| project-rename privateEndpointConnections = properties_privateEndpointConnections
| project name, resourceGroup, ___location, subscriptionId, privateEndpointConnections['properties']['privateEndpoint']['id']
若要确定所有可用事件网格域的 输入架构 类型,请使用以下架构:
Resources
| where type == 'microsoft.eventgrid/domains'
| project name, resourceGroup, ___location, subscriptionId, properties['inputSchema']
若要识别所有可用事件网格主题的公共 网络访问 状态,请使用以下查询:
Resources
| where type == 'microsoft.eventgrid/topics'
| project name, resourceGroup, ___location, subscriptionId, properties['publicNetworkAccess']