c# - Azure 本地开发队列 ConnectionString

标签 c# azure azure-queues

我使用 VS 2013 中的 QueueWorkerRole 模板创建了一个新的 WorkerRole,它创建的代码如下所示:

        // Create the queue if it does not exist already
        var connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
        var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
        if (!namespaceManager.QueueExists(QueueName))
        {
            namespaceManager.CreateQueue(QueueName);
        }

        // Initialize the connection to Service Bus Queue
        _client = QueueClient.CreateFromConnectionString(connectionString, QueueName);

我遇到的问题是正确设置 Microsoft.ServiceBus.ConnectionString,以便它能够与在模拟器中运行的本地开发队列配合使用。默认情况下它的设置如下:

<appSettings>
    <!-- Service Bus specific app setings for messaging connections -->
    <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://[your namespace].servicebus.windows.net;SharedSecretIssuer=owner;SharedSecretValue=[your secret]" />
</appSettings>

我猜当我有一个托管服务要连接但我只是在本地尝试一些东西但无法连接它时,这会工作得很好。

我尝试过“UseDevelopmentStorage=True”,并且尝试使用在查看存储模拟器 UI“127.0.0.1:10001”时找到的地址以及使用我在此处找到的标准格式的本地模拟器:http://www.connectionstrings.com/windows-azure/ (DefaultEndpointsProtocol=https;AccountName=devstoreaccount1; AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;) 但我没有运气。

有时我会在计算模拟器 UI 中看到“服务总线连接字符串包含无效属性”,有时我会收到无法连接的错误。

谢谢。

最佳答案

您遇到的问题是您正在尝试将队列连接字符串插入服务总线连接字符串创建器。这两个连接字符串本质上是不同的。

要使用开发存储,您需要将要使用的应用程序设置键的值设置为:“UseDevelopmentStorage=true”,如以下堆栈溢出所示: Windows Azure Storage Emulator Connection String for ASP.NET MVC?这适用于存储(不适用于服务总线)

关于c# - Azure 本地开发队列 ConnectionString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19667500/

相关文章:

c# - ClickOnce部署网站修改

c# - 字符串参数的 ArgumentException 或 ArgumentNullException?

Azure 流分析 : remove duplicates while aggregating

azure - 如何判断 Azure CloudQueue.AddMessage 是否成功?

azure - Azure Key Vault 是否可以与函数一起使用来存储队列触发器的连接字符串?

c# - 使用 c# 和 asp.net 将 HTML 内容转换为 Pdf

c# - 在平面 map 上随机生成方 block

node.js - Azure Javascript SDK 无法为访问层为 'Archive' 的 Blob 复制 Blob (sync/beginCopyBlobUrl)

c# - 事件中心上 IoTHub 数据的概念

performance - Azure 存储队列在云中的辅助角色中速度非常慢,但在我的机器上则不然