c# - 如何处理 Azure 存储队列中的大消息?

标签 c# azure-storage azure-storage-queues

<分区>

我们使用几个 azure 函数和 azure 存储队列在它们之间进行通信。我们知道每个队列消息有 64kB 的限制,因此我们必须使用消息压缩,但有时我们会超过该限制。根据文档 https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted#capacity-and-quotas

Azure supports large messages by combining queues and blobs – at which point you can enqueue up to 200 GB for a single item.

看起来我们可以将大消息放入存储队列。不幸的是,没有关于此的其他文档。所以我们的问题是它应该如何运作?它应该开箱即用,或者我们应该使用一些模式,比如将消息写入 blob,将具有 blob id 的消息放入队列,而不是在一些队列触发的函数中通过 id 读取 blob?

我们使用 Microsoft.Azure.Storage.Queue v9.4.2 nuget 包将消息推送到队列中。

最佳答案

Azure 队列需要 CloudStorageAccount 来支持它。根据文档,CloudStorageAccount 可以是 Azure Blob Storage。

/* Include these "using" directives...
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
*/

string storageConnectionString = "DefaultEndpointsProtocol=https;"
    + "AccountName=[Storage Account Name]"
    + ";AccountKey=[Storage Account Key]"
    + ";EndpointSuffix=core.windows.net";

CloudStorageAccount account = CloudStorageAccount.Parse(storageConnectionString);

// Create the queue client.
CloudQueueClient queueClient = account.CreateCloudQueueClient();

我使用以下引用资料将其拼凑在一起:

https://learn.microsoft.com/en-us/azure/storage/queues/storage-dotnet-how-to-use-queues

https://learn.microsoft.com/en-us/dotnet/api/overview/azure/storage

关于c# - 如何处理 Azure 存储队列中的大消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54750315/

相关文章:

c# - Azure 数据表 - RowKey 作为 DateTime.Ticks 的正确用法?

azure - 授予对 azure 中存储帐户的访问权限

Azure 队列主体太大并超过最大允许限制

python - 如何使用 Python 访问 Azure 中的队列消息?

Azure存储队列-处理时间长

c# - 内存中的字节与字节数组

c# - CaSTLe Windsor IoC 属性注入(inject)简单操作方法

Azure Key Vault 与存储加密

c# - Azure 云存储凭据的保存位置

c# - 锁定线程与进程