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);
答案 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-practices和azure-event-hubs-processing)。