在Eventhub客户端创建中,设置必须为“name = value”形式

时间:2017-02-06 07:06:26

标签: azure azure-storage azureservicebus

Microsoft.WindowsAzure.Storage.dll中发生了'System.FormatException'类型的异常,但未在用户代码中处理

其他信息:设置的格式必须为“name = value”。

在EventHub中创建eventProcessorHost

 var eventProcessorHost = new EventProcessorHost(
                EhEntityPath,
                EventHubConsumerGroup.DefaultGroupName,
                EhConnectionString,
                StorageConnectionString,
                StorageContainerName);

示例值

 string EhConnectionString = "Endpoint=sb://namespacename-ns.servicebus.windows.net/;SharedAccessKeyName=receivepolicy;SharedAccessKey=v7IHIH+jB3+H2UMxEOr9kHYfhwj1Q=;EntityPath=sampleeventhub";
 string EhEntityPath = "sampleeventhub";
 string StorageContainerName = "containername"; //I have created in blob and type as container
 string StorageAccountName = "storegenameinazure";
 string StorageAccountKey = "GHasmRRJgI5s123ziDlfOKQ7IBrO23EvHpk++TV0L2hU2erdI7PyY+gtvUop67lIU0+zQsM09sQ==";

  static readonly string StorageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, StorageAccountKey);

1 个答案:

答案 0 :(得分:1)

根据您的描述,我利用Microsoft.Azure.ServiceBus.EventProcessorHost版本(2.2.10)来测试此问题。

  

Microsoft.WindowsAzure.Storage.dll 中出现“System.FormatException”类型的异常,但未在用户代码中处理。其他信息:设置的格式必须为“name = value”

根据您的代码,我假设您没有正确构建EventProcessorHost构造函数,您使用的构造函数如下所示:

此时,您传递的参数StorageContainerName将被视为storageConnectionString参数,然后您收到上述错误。

总之,请使用正确的构造函数构建EventProcessorHost。以下是您可以参考的一些教程(event-processor-host-best-practicesazure-event-hubs-processing)。