Tar*_*huk 5 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
\n\n\n\n\nAzure 通过组合队列和 blob \xe2\x80\x93 来支持大消息,此时您可以为单个项目排队最多 200 GB。
\n
看起来我们可以将大消息放入存储队列中。不幸的是没有关于此的额外文档。所以我们的问题是它应该如何运作?它应该开箱即用,或者我们应该使用某种模式,例如将消息写入 blob,将带有 blob id 的消息放入队列,然后在某些队列触发的函数中按 id 读取 blob?
\n\n我们使用 Microsoft.Azure.Storage.Queue v9.4.2 nuget 包将消息推送到队列中。
\nAzure 队列需要 CloudStorageAccount 来支持。根据文档,该 CloudStorageAccount 可以是 Azure Blob 存储。
/* 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();
Run Code Online (Sandbox Code Playgroud)
我使用以下参考资料将其拼凑在一起:
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