本文讨论将 Blob 存储用作检查点存储的问题。
使用 Blob 存储作为检查点存储的问题
使用 Blob 存储帐户作为检查点存储时可能会出现问题,这些问题与处理延迟相关,或者使用 SDK 时创建检查点失败等。
使用 Azure Blob 存储作为检查点存储时,请遵循以下建议:
- 对每个使用者组使用单独的容器。 可以使用同一存储帐户,但每个组使用一个容器。
- 不要将存储帐户用于任何其他用途。
- 不要将容器用于任何其他用途。
- 在部署的应用程序所在的同一区域中创建存储帐户。 如果应用程序位于本地,请尝试选择最近的区域。
在 Azure 门户的“存储帐户”页上的“Blob 服务”部分,确保禁用以下设置。
- 分层命名空间
- Blob 软删除
- 版本控制
使用 Blob 存储作为 Azure Stack Hub 上的检查点存储
如果将 Azure Blob 存储用作支持不同版本的存储 Blob SDK 的环境中的检查点存储,则需使用代码将存储服务 API 版本更改为该环境支持的特定版本。 例如,如果在 Azure Stack Hub 版本 2002 上运行事件中心,则存储服务的最高可用版本是版本 2017-11-09。 在这种情况下,需要使用代码将存储服务 API 版本定向到 2017-11-09。 有关如何以特定存储 API 版本为目标的示例,请参阅 GitHub 上的以下示例:
- .NET
- Java。
- JavaScript 或 TypeScript
- Python - 同步、异步
如果不针对 Azure Stack Hub 支持的版本运行使用 Blob 存储作为检查点存储的事件中心接收器,则会收到以下错误消息:
The value for one of the HTTP headers is not in the correct format
Python 中的示例错误消息
对于 Python,错误 azure.core.exceptions.HttpResponseError
被传递给 on_error(partition_context, error)
的错误处理器 EventHubConsumerClient.receive()
。 但是,该方法 receive()
不会引发异常。
print(error)
输出以下异常信息:
The value for one of the HTTP headers is not in the correct format.
RequestId:f048aee8-a90c-08ba-4ce1-e69dba759297
Time:2020-03-17T22:04:13.3559296Z
ErrorCode:InvalidHeaderValue
Error:None
HeaderName:x-ms-version
HeaderValue:2019-07-07
记录器记录两个警告,如下所示:
WARNING:azure.eventhub.extensions.checkpointstoreblobaio._blobstoragecsaio:
An exception occurred during list_ownership for namespace '<namespace-name>.eventhub.<region>.azurestack.corp.microsoft.com' eventhub 'python-eh-test' consumer group '$Default'.
Exception is HttpResponseError('The value for one of the HTTP headers is not in the correct format.\nRequestId:f048aee8-a90c-08ba-4ce1-e69dba759297\nTime:2020-03-17T22:04:13.3559296Z\nErrorCode:InvalidHeaderValue\nError:None\nHeaderName:x-ms-version\nHeaderValue:2019-07-07')
WARNING:azure.eventhub.aio._eventprocessor.event_processor:EventProcessor instance '26d84102-45b2-48a9-b7f4-da8916f68214' of eventhub 'python-eh-test' consumer group '$Default'. An error occurred while load-balancing and claiming ownership.
The exception is HttpResponseError('The value for one of the HTTP headers is not in the correct format.\nRequestId:f048aee8-a90c-08ba-4ce1-e69dba759297\nTime:2020-03-17T22:04:13.3559296Z\nErrorCode:InvalidHeaderValue\nError:None\nHeaderName:x-ms-version\nHeaderValue:2019-07-07'). Retrying after 71.45254944090853 seconds
后续步骤
请参阅以下文章,了解分区和检查点: 在应用程序的多个实例之间均衡分区负载