QueueClient Class
A client to interact with a specific Queue.
- Inheritance
-
azure.storage.queue._shared.base_client_async.AsyncStorageAccountHostsMixinQueueClientazure.storage.queue._shared.base_client.StorageAccountHostsMixinQueueClientazure.storage.queue._encryption.StorageEncryptionMixinQueueClient
Constructor
QueueClient(account_url: str, queue_name: str, credential: str | Dict[str, str] | AzureNamedKeyCredential | AzureSasCredential | AsyncTokenCredential | None = None, **kwargs: Any)
Parameters
Name | Description |
---|---|
account_url
Required
|
The URL to the storage account. In order to create a client given the full URI to the queue, use the from_queue_url classmethod. |
queue_name
Required
|
The name of the queue. |
credential
|
AzureNamedKeyCredential or
AzureSasCredential or
AsyncTokenCredential or
str or
dict[str, str] or
None
The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials, an account shared access key, or an instance of a TokenCredentials class from azure.identity. If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential
Default value: None
|
Keyword-Only Parameters
Name | Description |
---|---|
api_version
|
The Storage API version to use for requests. Default value is the most recent service version that is compatible with the current SDK. Setting to an older version may result in reduced feature compatibility. |
secondary_hostname
|
The hostname of the secondary endpoint. |
message_encode_policy
|
The encoding policy to use on outgoing messages. Default is not to encode messages. Other options include <xref:azure.storage.queue.aio.TextBase64EncodePolicy>, <xref:azure.storage.queue.aio.BinaryBase64EncodePolicy> or None. |
message_decode_policy
|
The decoding policy to use on incoming messages. Default value is not to decode messages. Other options include <xref:azure.storage.queue.aio.TextBase64DecodePolicy>, <xref:azure.storage.queue.aio.BinaryBase64DecodePolicy> or None. |
audience
|
The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.queue.core.windows.net. |
Examples
Create the queue client with url and credential.
token_auth_queue = QueueClient.from_queue_url(
queue_url=queue.url,
credential=sas_token
)
Create the queue client with a connection string.
from azure.storage.queue.aio import QueueClient
queue = QueueClient.from_connection_string(self.connection_string, "myqueue1")
Methods
clear_messages |
Deletes all messages from the specified queue. |
close |
This method is to close the sockets opened by the client. It need not be used when using with a context manager. |
create_queue |
Creates a new queue in the storage account. If a queue with the same name already exists, the operation fails with a ResourceExistsError. |
delete_message |
Deletes the specified message. Normally after a client retrieves a message with the receive messages operation, the client is expected to process and delete the message. To delete the message, you must have the message object itself, or two items of data: id and pop_receipt. The id is returned from the previous receive_messages operation. The pop_receipt is returned from the most recent receive_messages or update_message operation. In order for the delete_message operation to succeed, the pop_receipt specified on the request must match the pop_receipt returned from the receive_messages or update_message operation. |
delete_queue |
Deletes the specified queue and any messages it contains. When a queue is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The queue is later removed from the Queue service during garbage collection. Note that deleting a queue is likely to take at least 40 seconds to complete. If an operation is attempted against the queue while it was being deleted, an <xref:azure.storage.queue.aio.HttpResponseError> will be thrown. |
from_connection_string |
Create QueueClient from a Connection String. |
from_queue_url |
A client to interact with a specific Queue. |
get_queue_access_policy |
Returns details about any stored access policies specified on the queue that may be used with Shared Access Signatures. |
get_queue_properties |
Returns all user-defined metadata for the specified queue. The data returned does not include the queue's list of messages. |
peek_messages |
Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message. Only messages that are visible may be retrieved. When a message is retrieved for the first time with a call to receive_messages, its dequeue_count property is set to 1. If it is not deleted and is subsequently retrieved again, the dequeue_count property is incremented. The client may use this value to determine how many times a message has been retrieved. Note that a call to peek_messages does not increment the value of dequeue_count, but returns this value for the client to read. If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned. |
receive_message |
Removes one message from the front of the queue. When the message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter. If the key-encryption-key or resolver field is set on the local service object, the message will be decrypted before being returned. |
receive_messages |
Removes one or more messages from the front of the queue. When a message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter. The iterator will continuously fetch messages until the queue is empty or max_messages is reached (if max_messages is set). If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned. |
send_message |
Adds a new message to the back of the message queue. The visibility timeout specifies the time that the message will be invisible. After the timeout expires, the message will become visible. If a visibility timeout is not specified, the default value of 0 is used. The message time-to-live specifies how long a message will remain in the queue. The message will be deleted from the queue when the time-to-live period expires. If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading. |
set_queue_access_policy |
Sets stored access policies for the queue that may be used with Shared Access Signatures. When you set permissions for a queue, the existing permissions are replaced. To update the queue's permissions, call get_queue_access_policy to fetch all access policies associated with the queue, modify the access policy that you wish to change, and then call this function with the complete set of data to perform the update. When you establish a stored access policy on a queue, it may take up to 30 seconds to take effect. During this interval, a shared access signature that is associated with the stored access policy will throw an <xref:azure.storage.queue.aio.HttpResponseError> until the access policy becomes active. |
set_queue_metadata |
Sets user-defined metadata on the specified queue. Metadata is associated with the queue as name-value pairs. |
update_message |
Updates the visibility timeout of a message. You can also use this operation to update the contents of a message. This operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker role calls receive_messages and recognizes that it needs more time to process a message, it can continually extend the message's invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it. If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading. |
clear_messages
Deletes all messages from the specified queue.
async clear_messages(**kwargs: Any) -> None
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Examples
Clears all messages.
await queue.clear_messages()
close
This method is to close the sockets opened by the client. It need not be used when using with a context manager.
async close()
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
create_queue
Creates a new queue in the storage account.
If a queue with the same name already exists, the operation fails with a ResourceExistsError.
async create_queue(*, metadata: Dict[str, str] | None = None, **kwargs: Any) -> None
Keyword-Only Parameters
Name | Description |
---|---|
metadata
|
A dict containing name-value pairs to associate with the queue as metadata. Note that metadata names preserve the case with which they were created, but are case-insensitive when set or read. |
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
None or the result of cls(response) |
Exceptions
Type | Description |
---|---|
StorageErrorException
|
Examples
Create a queue.
await queue.create_queue()
delete_message
Deletes the specified message.
Normally after a client retrieves a message with the receive messages operation, the client is expected to process and delete the message. To delete the message, you must have the message object itself, or two items of data: id and pop_receipt. The id is returned from the previous receive_messages operation. The pop_receipt is returned from the most recent receive_messages or update_message operation. In order for the delete_message operation to succeed, the pop_receipt specified on the request must match the pop_receipt returned from the receive_messages or update_message operation.
async delete_message(message: str | QueueMessage, pop_receipt: str | None = None, **kwargs: Any) -> None
Parameters
Name | Description |
---|---|
message
Required
|
str or
QueueMessage
The message object or id identifying the message to delete. |
pop_receipt
Required
|
A valid pop receipt value returned from an earlier call to the receive_messages or update_message. |
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Examples
Delete a message.
# Get the message at the front of the queue
messages = queue.receive_messages()
async for msg in messages:
# Delete the specified message
await queue.delete_message(msg)
delete_queue
Deletes the specified queue and any messages it contains.
When a queue is successfully deleted, it is immediately marked for deletion and is no longer accessible to clients. The queue is later removed from the Queue service during garbage collection.
Note that deleting a queue is likely to take at least 40 seconds to complete. If an operation is attempted against the queue while it was being deleted, an <xref:azure.storage.queue.aio.HttpResponseError> will be thrown.
async delete_queue(**kwargs: Any) -> None
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
Examples
Delete a queue.
await queue.delete_queue()
from_connection_string
Create QueueClient from a Connection String.
from_connection_string(conn_str: str, queue_name: str, credential: str | Dict[str, str] | AzureNamedKeyCredential | AzureSasCredential | AsyncTokenCredential | None = None, **kwargs: Any) -> Self
Parameters
Name | Description |
---|---|
conn_str
Required
|
A connection string to an Azure Storage account. |
queue_name
Required
|
The queue name. |
credential
|
AzureNamedKeyCredential or
AzureSasCredential or
AsyncTokenCredential or
str or
dict[str, str] or
None
The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared access key values. The value can be a SAS token string, an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials, an account shared access key, or an instance of a TokenCredentials class from azure.identity. Credentials provided here will take precedence over those in the connection string. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. Default value: None
|
Keyword-Only Parameters
Name | Description |
---|---|
audience
|
The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.queue.core.windows.net. |
Returns
Type | Description |
---|---|
A queue client. |
Examples
Create the queue client from connection string.
from azure.storage.queue import QueueClient
queue = QueueClient.from_connection_string(self.connection_string, "myqueue1")
from_queue_url
A client to interact with a specific Queue.
from_queue_url(queue_url: str, credential: str | Dict[str, str] | AzureNamedKeyCredential | AzureSasCredential | AsyncTokenCredential | None = None, **kwargs: Any) -> Self
Parameters
Name | Description |
---|---|
queue_url
Required
|
The full URI to the queue, including SAS token if used. |
credential
|
AzureNamedKeyCredential or
AzureSasCredential or
AsyncTokenCredential or
str or
dict[str, str] or
None
The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials, an account shared access key, or an instance of a TokenCredentials class from azure.identity. If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential
Default value: None
|
Keyword-Only Parameters
Name | Description |
---|---|
audience
|
The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.queue.core.windows.net. |
Returns
Type | Description |
---|---|
A queue client. |
get_queue_access_policy
Returns details about any stored access policies specified on the queue that may be used with Shared Access Signatures.
async get_queue_access_policy(**kwargs: Any) -> Dict[str, AccessPolicy]
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
A dictionary of access policies associated with the queue. |
get_queue_properties
Returns all user-defined metadata for the specified queue.
The data returned does not include the queue's list of messages.
async get_queue_properties(**kwargs: Any) -> QueueProperties
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
The timeout parameter is expressed in seconds. |
Returns
Type | Description |
---|---|
User-defined metadata for the queue. |
Examples
Get the properties on the queue.
properties = await queue.get_queue_properties()
peek_messages
Retrieves one or more messages from the front of the queue, but does not alter the visibility of the message.
Only messages that are visible may be retrieved. When a message is retrieved for the first time with a call to receive_messages, its dequeue_count property is set to 1. If it is not deleted and is subsequently retrieved again, the dequeue_count property is incremented. The client may use this value to determine how many times a message has been retrieved. Note that a call to peek_messages does not increment the value of dequeue_count, but returns this value for the client to read.
If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.
async peek_messages(max_messages: int | None = None, **kwargs: Any) -> List[QueueMessage]
Parameters
Name | Description |
---|---|
max_messages
Required
|
A nonzero integer value that specifies the number of messages to peek from the queue, up to a maximum of 32. By default, a single message is peeked from the queue with this operation. |
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
A list of QueueMessage objects. Note that next_visible_on and pop_receipt will not be populated as peek does not pop the message and can only retrieve already visible messages. |
Examples
Peek messages.
# Peek at one message at the front of the queue
msg = await queue.peek_messages()
# Peek at the last 5 messages
messages = await queue.peek_messages(max_messages=5)
# Print the last 5 messages
for message in messages:
print(message.content)
receive_message
Removes one message from the front of the queue.
When the message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter.
If the key-encryption-key or resolver field is set on the local service object, the message will be decrypted before being returned.
async receive_message(*, visibility_timeout: int | None = None, **kwargs: Any) -> QueueMessage | None
Keyword-Only Parameters
Name | Description |
---|---|
visibility_timeout
|
If not specified, the default value is 30. Specifies the new visibility timeout value, in seconds, relative to server time. The value must be larger than or equal to 1, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. visibility_timeout should be set to a value smaller than the time-to-live value. |
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
Returns a message from the Queue or None if the Queue is empty. |
Examples
Receive one message from the queue.
# Pop two messages from the front of the queue
message1 = await queue.receive_message()
message2 = await queue.receive_message()
# We should see message 3 if we peek
message3 = await queue.peek_messages()
if not message1 or not message2 or not message3:
raise ValueError("One of the messages are None.")
print(message1.content)
print(message2.content)
print(message3[0].content)
receive_messages
Removes one or more messages from the front of the queue.
When a message is retrieved from the queue, the response includes the message content and a pop_receipt value, which is required to delete the message. The message is not automatically deleted from the queue, but after it has been retrieved, it is not visible to other clients for the time interval specified by the visibility_timeout parameter. The iterator will continuously fetch messages until the queue is empty or max_messages is reached (if max_messages is set).
If the key-encryption-key or resolver field is set on the local service object, the messages will be decrypted before being returned.
receive_messages(*, messages_per_page: int | None = None, visibility_timeout: int | None = None, max_messages: int | None = None, **kwargs: Any) -> AsyncItemPaged[QueueMessage]
Keyword-Only Parameters
Name | Description |
---|---|
messages_per_page
|
A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of 32. If fewer are visible, the visible messages are returned. By default, a single message is retrieved from the queue with this operation. by_page() can be used to provide a page iterator on the AsyncItemPaged if messages_per_page is set. next() can be used to get the next page. |
visibility_timeout
|
If not specified, the default value is 30. Specifies the new visibility timeout value, in seconds, relative to server time. The value must be larger than or equal to 1, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. visibility_timeout should be set to a value smaller than the time-to-live value. |
max_messages
|
An integer that specifies the maximum number of messages to retrieve from the queue. |
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
Returns a message iterator of dict-like Message objects. |
Examples
Receive messages from the queue.
# Receive messages one-by-one
messages = queue.receive_messages()
async for msg in messages:
print(msg.content)
# Receive messages by batch
messages = queue.receive_messages(messages_per_page=5)
async for msg_batch in messages.by_page():
async for msg in msg_batch:
print(msg.content)
await queue.delete_message(msg)
send_message
Adds a new message to the back of the message queue.
The visibility timeout specifies the time that the message will be invisible. After the timeout expires, the message will become visible. If a visibility timeout is not specified, the default value of 0 is used.
The message time-to-live specifies how long a message will remain in the queue. The message will be deleted from the queue when the time-to-live period expires.
If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.
async send_message(content: object | None, *, visibility_timeout: int | None = None, time_to_live: int | None = None, **kwargs: Any) -> QueueMessage
Parameters
Name | Description |
---|---|
content
Required
|
Message content. Allowed type is determined by the encode_function set on the service. Default is str. The encoded message can be up to 64KB in size. |
Keyword-Only Parameters
Name | Description |
---|---|
visibility_timeout
|
If not specified, the default value is 0. Specifies the new visibility timeout value, in seconds, relative to server time. The value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. visibility_timeout should be set to a value smaller than the time-to-live value. |
time_to_live
|
Specifies the time-to-live interval for the message, in seconds. The time-to-live may be any positive number or -1 for infinity. If this parameter is omitted, the default time-to-live is 7 days. |
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
A QueueMessage object. This object is also populated with the content although it is not returned from the service. |
Examples
Send messages.
await asyncio.gather(
queue.send_message("message1"),
queue.send_message("message2", visibility_timeout=30), # wait 30s before becoming visible
queue.send_message("message3"),
queue.send_message("message4"),
queue.send_message("message5")
)
set_queue_access_policy
Sets stored access policies for the queue that may be used with Shared Access Signatures.
When you set permissions for a queue, the existing permissions are replaced. To update the queue's permissions, call get_queue_access_policy to fetch all access policies associated with the queue, modify the access policy that you wish to change, and then call this function with the complete set of data to perform the update.
When you establish a stored access policy on a queue, it may take up to 30 seconds to take effect. During this interval, a shared access signature that is associated with the stored access policy will throw an <xref:azure.storage.queue.aio.HttpResponseError> until the access policy becomes active.
async set_queue_access_policy(signed_identifiers: Dict[str, AccessPolicy], **kwargs: Any) -> None
Parameters
Name | Description |
---|---|
signed_identifiers
Required
|
SignedIdentifier access policies to associate with the queue. This may contain up to 5 elements. An empty dict will clear the access policies set on the service. |
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Examples
Set an access policy on the queue.
# Create an access policy
from azure.storage.queue import AccessPolicy, QueueSasPermissions
access_policy = AccessPolicy()
access_policy.start = datetime.utcnow() - timedelta(hours=1)
access_policy.expiry = datetime.utcnow() + timedelta(hours=1)
access_policy.permission = QueueSasPermissions(read=True)
identifiers = {'my-access-policy-id': access_policy}
# Set the access policy
await queue.set_queue_access_policy(identifiers)
set_queue_metadata
Sets user-defined metadata on the specified queue.
Metadata is associated with the queue as name-value pairs.
async set_queue_metadata(metadata: Dict[str, str] | None = None, **kwargs: Any) -> Dict[str, Any]
Parameters
Name | Description |
---|---|
metadata
Required
|
A dict containing name-value pairs to associate with the queue as metadata. |
Keyword-Only Parameters
Name | Description |
---|---|
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
A dictionary of response headers. |
Examples
Set metadata on the queue.
metadata = {'foo': 'val1', 'bar': 'val2', 'baz': 'val3'}
await queue.set_queue_metadata(metadata=metadata)
update_message
Updates the visibility timeout of a message. You can also use this operation to update the contents of a message.
This operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to "lease" a queue message. For example, if a worker role calls receive_messages and recognizes that it needs more time to process a message, it can continually extend the message's invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it.
If the key-encryption-key field is set on the local service object, this method will encrypt the content before uploading.
async update_message(message: str | QueueMessage, pop_receipt: str | None = None, content: object | None = None, *, visibility_timeout: int | None = None, **kwargs: Any) -> QueueMessage
Parameters
Name | Description |
---|---|
message
Required
|
str or
QueueMessage
The message object or id identifying the message to update. |
pop_receipt
Required
|
A valid pop receipt value returned from an earlier call to the receive_messages or update_message operation. |
content
Required
|
Message content. Allowed type is determined by the encode_function set on the service. Default is str. |
Keyword-Only Parameters
Name | Description |
---|---|
visibility_timeout
|
Specifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. A message can be updated until it has been deleted or has expired. The message object or message id identifying the message to update. |
timeout
|
Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see here. |
Returns
Type | Description |
---|---|
A QueueMessage object. For convenience, this object is also populated with the content, although it is not returned by the service. |
Examples
Update a message.
# Send a message
await queue.send_message("update me")
# Receive the message
messages = queue.receive_messages()
# Update the message
async for message in messages:
message = await queue.update_message(
message,
visibility_timeout=0,
content="updated")
Attributes
api_version
location_mode
The location mode that the client is currently using.
By default this will be "primary". Options include "primary" and "secondary".
Returns
Type | Description |
---|---|
primary_endpoint
primary_hostname
secondary_endpoint
The full secondary endpoint URL if configured.
If not available a ValueError will be raised. To explicitly specify a secondary hostname, use the optional secondary_hostname keyword argument on instantiation.
Returns
Type | Description |
---|---|
Exceptions
Type | Description |
---|---|
secondary_hostname
The hostname of the secondary endpoint.
If not available this will be None. To explicitly specify a secondary hostname, use the optional secondary_hostname keyword argument on instantiation.
Returns
Type | Description |
---|---|
url
The full endpoint URL to this entity, including SAS token if used.
This could be either the primary endpoint, or the secondary endpoint depending on the current location_mode. :returns: The full endpoint URL to this entity, including SAS token if used. :rtype: str
Azure SDK for Python