Azure Service Bus connection string results in CloudStorageAccount.Parse error

纵饮孤独 提交于 2020-01-16 05:12:06

问题


The following call

CloudStorageAccount.Parse(<connection-string>);

returns this error:

"No valid combination of account information found."

with the connection string copied directly from the CONNECTION STRING–PRIMARY KEY field on the Azure service Bus Access Policies -> Policy blade, which looks like this:

Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=xxx;SharedAccessKey=xxx;EntityPath=xxx

I need CloudQueueClient and CloudQueue instances to do queue manipulation. Am I missing something obvious, or is there another way to initialise CloudStorageAccount?

Update: the following syntax allows me to add a new queue using the service level (not queue level) credentials, but I'm not sure how I get from here to a CloudQueue or CloudQueueClient instance.

var queueNamespace = NamespaceManager.CreateFromConnectionString(
     "Endpoint=sb://<service-account>.servicebus.windows.net/;
     SharedAccessKeyName=sharedaccess;
     SharedAccessKey=xxx");

回答1:


The reason you're getting this error is because you're trying to use storage client library for Service Bus resources. Microsoft.WindowsAzure.Storage is the client library for Azure Storage. Queues in Azure Storage are not a Service Bus Queues.

For Service Bus queues you would need to use its client library that you can install via Nuget from https://www.nuget.org/packages/WindowsAzure.ServiceBus/.

Once you do that, you should be able to create a NamespaceManager using the following code:

var manager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(ConnectionString);

and then you will be able to perform operations on your Service Bus Queues.

You may find this link useful as well: https://azure.microsoft.com/en-in/documentation/articles/service-bus-dotnet-get-started-with-queues/.



来源:https://stackoverflow.com/questions/38648656/azure-service-bus-connection-string-results-in-cloudstorageaccount-parse-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!