azure - 创建可以处理多个队列的 Azure.Storage.Queues 客户端

标签 azure azure-storage azure-queues azure-storage-queues

我正在将代码从 Microsoft.WindowsAzure.Storage.Queue 迁移到 Azure.Storage.Queues。在我的应用程序中,我将使用的所有队列操作包装在 MyQueueClient 类中。创建队列客户端的旧方法如下:

CloudStorageAccount account = CloudStorageAccount.Parse(ConnectionString);
CloudQueueClient client = account.CreateCloudQueueClient();

因为我有多个队列,所以这种方法对我来说效果很好。在新方法中,看起来我需要将队列名称作为参数之一传递来创建队列客户端 - 请参阅文档:https://learn.microsoft.com/en-us/azure/storage/queues/storage-dotnet-how-to-use-queues?tabs=dotnet#create-the-queue-service-client

QueueClient queueClient = new QueueClient(connectionString, queueName);

所以,我有点困惑。这是否意味着我必须为我使用的每个队列创建一个单独的队列客户端?假设我有 3 个队列,这是否意味着我必须创建 3 个队列客户端?似乎没有道理。我在这里缺少什么?

最佳答案

您可以使用以下代码:

        QueueServiceClient queueServiceClient = new QueueServiceClient(connectionString);

然后就可以使用基于queueServiceClient的方法了(注意,与旧的相比,它可能有一些限制)。

enter image description here

关于azure - 创建可以处理多个队列的 Azure.Storage.Queues 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64887427/

相关文章:

android - android 的窗口 azure 移动服务根据不同的值获取多条记录

azure - 如何找到 Azure 存储帐户上的热 LRS 写入操作的来源?

azure - Snowpipe 云消息传递机制在 Azure 上到底如何工作?

azure - 将 Azure 队列消息复制到另一个存储帐户

sql - 使用 BizTalk 混合连接从 Azure 外部的应用程序连接到本地 SQL

azure - 使用 Azure AD B2C 管理权限

powershell - Azure PowerShell blob 下载 - 确认 不总是

azure - Azure 中的 Rabbit MQ 支持

azure - 死信规则如何在 azure 托管服务总线中发挥作用?

c# - 如何创建文件或将文件上传到 Azure Data Lake Storage Gen2