0

I am not familiar with Azure Queue very well and faced with different approaches in Azure docs.

  • First approach is said that we can use Queue attribute and ICollector. Using that parameter we can simply Add() messages.
  • Second approach is said that we have QueueClient and we can create an instance of that class and write messages too.

Which pros and cons do these approaches have? What is the best to use?

Ilya
  • 5
  • 3

1 Answers1

0

https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.webjobs.queueattribute?view=azure-dotnet:
Attribute used to bind a parameter to an Azure Queue.
The method parameter type can be one of the following:

  • QueueClient
  • Microsoft.Azure.WebJobs.ICollector1 of these types (to - enqueue multiple messages via Microsoft.Azure.WebJobs.ICollector1.Add(0) (removed ` due to SO formatting)

You can write multiple messages to the queue by using one of the following types:

  • ICollector or IAsyncCollector
  • CloudQueue

... is an ICollector type, representing a collection of messages written to an output binding when the function completes. You can send multiple messages at once by using an ICollector.

https://learn.microsoft.com/en-us/dotnet/api/azure.storage.queues.queueclient?view=azure-dotnet
A QueueClient represents a URI to the Azure Storage Queue service allowing you to manipulate a queue. https://learn.microsoft.com/en-us/java/api/com.azure.storage.queue.queueclient?view=azure-java-stable "This class provides a client that contains all the operations for interacting with a queue in Azure Storage Queue. Operations allowed by the client are creating and deleting the queue, retrieving and updating metadata and access policies of the queue, and enqueuing, dequeuing, peeking, updating, and deleting messages."

See this answer too: Azure Functions: ICollector<T> vs IAsyncCollector<T>

Niclas
  • 1,069
  • 4
  • 18
  • 33