QueueClientOptions Class


Provides the client configuration options for connecting to Azure Queue Storage

public class QueueClientOptions : Azure.Core.ClientOptions
type QueueClientOptions = class
    inherit ClientOptions
Public Class QueueClientOptions
Inherits ClientOptions



Initializes a new instance of the QueueClientOptions class.



Gets the client diagnostic options.

(Inherited from ClientOptions)

Enables tenant discovery through the authorization challenge when the client is configured to use a TokenCredential. When enabled, the client will attempt an initial un-authorized request to prompt a challenge in order to discover the correct tenant for the resource.


Gets or sets the secondary storage Uri that can be read from for the storage account if the account is enabled for RA-GRS.

If this property is set, the secondary Uri will be used for GET or HEAD requests during retries. If the status of the response from the secondary Uri is a 404, then subsequent retries for the request will not use the secondary Uri again, as this indicates that the resource may not have propagated there yet. Otherwise, subsequent retries will alternate back and forth between primary and secondary Uri.


Gets or sets a message encoding that determines how Body is represented in HTTP requests and responses. The default is None.


Gets the client retry options.

(Inherited from ClientOptions)

The HttpPipelineTransport to be used for this client. Defaults to an instance of HttpClientTransport.

(Inherited from ClientOptions)

Gets the QueueClientOptions.ServiceVersion of the service API used when making requests. For more, see For more information, see Versioning for the Azure Storage services.


AddPolicy(HttpPipelinePolicy, HttpPipelinePosition)

Adds an HttpPipeline policy into the client pipeline. The position of policy in the pipeline is controlled by position parameter. If you want the policy to execute once per client request use PerCall otherwise use PerRetry to run the policy for every retry. Note that the same instance of policy would be added to all pipelines of client constructed using this ClientOptions object.

(Inherited from ClientOptions)



Optional. Performs the tasks needed when a message is received or peaked from the queue but cannot be decoded.

Such message can be received or peaked when QueueClient is expecting certain QueueMessageEncoding but there's another producer that is not encoding messages in expected way. I.e. the queue contains messages with different encoding.

QueueMessageDecodingFailedEventArgs contains QueueClient that has received the message as well as ReceivedMessage or PeekedMessage with raw body, i.e. no decoding will be attempted so that body can be inspected as has been received from the queue.

The QueueClient won't attempt to remove the message from the queue. Therefore such handling should be included into the event handler itself.

The handler is potentially invoked by both synchronous and asynchronous receive and peek APIs. Therefore implementation of the handler should align with QueueClient APIs that are being used. See SyncAsyncEventHandler<T> about how to implement handler correctly. The example below shows a handler with all possible cases explored.

QueueClientOptions queueClientOptions = new QueueClientOptions()
    MessageEncoding = QueueMessageEncoding.Base64

queueClientOptions.MessageDecodingFailed += async (QueueMessageDecodingFailedEventArgs args) =>
    if (args.PeekedMessage != null)
        Console.WriteLine($"Invalid message has been peeked, message id={args.PeekedMessage.MessageId} body={args.PeekedMessage.Body}");
    else if (args.ReceivedMessage != null)
        Console.WriteLine($"Invalid message has been received, message id={args.ReceivedMessage.MessageId} body={args.ReceivedMessage.Body}");

        if (args.IsRunningSynchronously)
            args.Queue.DeleteMessage(args.ReceivedMessage.MessageId, args.ReceivedMessage.PopReceipt);
            await args.Queue.DeleteMessageAsync(args.ReceivedMessage.MessageId, args.ReceivedMessage.PopReceipt);

QueueClient queueClient = new QueueClient(connectionString, queueName, queueClientOptions);

Applies to