使用 Blob 存储作为检查点存储 - Azure Stack Hub(预览版)上的事件中心Use Blob Storage as checkpoint store - Event Hubs on Azure Stack Hub (preview)

如果你在一个环境中使用 Azure Blob 存储作为检查点存储,该环境支持与 Azure 上通常可用的存储 Blob SDK 版本不同的版本,那么你需要使用代码将存储服务 API 版本更改为该环境支持的特定版本。If you're using Azure Blob Storage as the checkpoint store in an environment that supports a different version of Storage Blob SDK than the ones that are typically available on Azure, you'll need to use code to change the Storage service API version to the specific version supported by that environment. 例如,如果运行基于 Azure Stack Hub 版本 2002 的事件中心,则存储服务的最高可用版本为 2017-11-09。For example, if you're running Event Hubs on an Azure Stack Hub version 2002, the highest available version for the Storage service is version 2017-11-09. 在这种情况下,需要使用代码将存储服务 API 版本设定为 2017-11-09。In this case, you need to use code to target the Storage service API version to 2017-11-09. 如需通过示例来了解如何以特定的存储 API 版本为目标,请参阅“GitHub 上的这些示例”:For an example on how to target a specific Storage API version, see these samples on GitHub:

如果不针对 Azure Stack Hub 支持的版本运行使用 Blob 存储作为检查点存储的事件中心接收器,则会收到以下错误消息:If you run Event Hubs receiver that uses Blob Storage as the checkpoint store without targeting the version that Azure Stack Hub supports, you'll receive the following error message:

The value for one of the HTTP headers is not in the correct format

Python 中的示例错误消息Sample error message in Python

对于 Python,错误 azure.core.exceptions.HttpResponseError 将传递到 EventHubConsumerClient.receive() 的错误处理程序 on_error(partition_context, error)For Python, an error of azure.core.exceptions.HttpResponseError is passed to the error handler on_error(partition_context, error) of EventHubConsumerClient.receive(). 但是,receive() 方法不会引发异常。But, the method receive() doesn't raise an exception. print(error) 将输出以下异常信息:print(error) will print the following exception information:

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

记录器将记录两个警告,如下所示:The logger will log two warnings like the following ones:

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

后续步骤Next steps

请参阅以下文章,了解分区和检查点:跨应用程序的多个实例均衡分区负载See the following article learn about partitioning and checkpointing: Balance partition load across multiple instances of your application