Package: azure-servicebus
Azure Service Bus client library for PythonAzure Service Bus is a high performance cloud-managed messaging service for providing real-time and fault-tolerant communication between distributed senders and receivers.Service Bus provides multiple mechanisms for asynchronous highly reliable communication, such as structured first-in-first-out messaging,
publish/subscribe capabilities, and the ability to easily scale as your needs grow.Use the Service Bus client library for Python to communicate between applications and services and implement asynchronous messaging patterns.Create Service Bus namespaces, queues, topics, and subscriptions, and modify their settings.Send and receive messages within your Service Bus channels.Utilize message locks, sessions, and dead letter functionality to implement complex messaging patterns.Source code|Package (PyPi)|Package (Conda)|API reference documentation|Product documentation|Samples|ChangelogNOTE: If you are using version 0.50 or lower and want to migrate to the latest version
of this package please look at ourmigration guide to move from Service Bus V0.50 to Service Bus V7.Getting startedInstall the packageInstall the Azure Service Bus client library for Python withpip:pipinstallazure-servicebusPrerequisites:To use this package, you must have:Azure subscription -Create a free accountAzure Service Bus -Namespace and management credentialsPython 3.7 or later -Install PythonIf you need an Azure service bus namespace, you can create it via theAzure Portal.
If you do not wish to use the graphical portal UI, you can use the Azure CLI viaCloud Shell, or Azure CLI run locally, to create one with this Azure CLI command:azservicebusnamespacecreate--resource-group<resource-group-name>--name<servicebus-namespace-name>--location<servicebus-namespace-location>Authenticate the clientInteraction with Service Bus starts with an instance of theServiceBusClientclass. You either need aconnection string with SAS key, or anamespaceand one of itsaccount keysto instantiate the client object.
Please find the samples linked below for demonstration as to how to authenticate via either approach.Create client from connection stringTo obtain the required credentials, one can use theAzure CLIsnippet (Formatted for Bash Shell) at the top of the linked sample to populate an environment variable with the service bus connection string (you can also find these values in theAzure Portalby following the step-by-step guide toGet a service bus connection string).Create client using the azure-identity library:This constructor takes the fully qualified namespace of your Service Bus instance and a credential that implements theTokenCredentialprotocol. There are implementations of theTokenCredentialprotocol available in theazure-identity package. The fully qualified namespace is of the format<yournamespace.servicebus.windows.net>.To use the credential types provided byazure-identity, please install the package:pip install azure-identityAdditionally, to use the async API, you must first install an async transport, such asaiohttp:pip install aiohttpWhen using Azure Active Directory, your principal must be assigned a role which allows access to Service Bus, such as the
Azure Service Bus Data Owner role. For more information about using Azure Active Directory authorization with Service Bus,
please refer tothe associated documentation.Note:client can be initialized without a context manager, but must be manually closed via client.close() to not leak resources.Key conceptsOnce you've initialized aServiceBusClient, you can interact with the primary resource types within a Service Bus Namespace, of which multiple can exist and on which actual message transmission takes place, the namespace often serving as an application container:Queue: Allows for Sending and Receiving of message.  Often used for point-to-point communication.Topic: As opposed to Queues, Topics are better suited to publish/subscribe scenarios.  A topic can be sent to, but requires a subscription, of which there can be multiple in parallel, to consume from.Subscription: The mechanism to consume from a Topic.  Each subscription is independent, and receives a copy of each message sent to the topic.  Rules and Filters can be used to tailor which messages are received by a specific subscription.For more information about these resources, seeWhat is Azure Service Bus?.To interact with these resources, one should be familiar with the following SDK concepts:ServiceBusClient: This is the object a user should first initialize to connect to a Service Bus Namespace.  To interact with a queue, topic, or subscription, one would spawn a sender or receiver off of this client.ServiceBusSender: To send messages to a Queue or Topic, one would use the correspondingget_queue_senderorget_topic_sendermethod off of aServiceBusClientinstance as seenhere.ServiceBusReceiver: To receive messages from a Queue or Subscription, one would use the correspondingget_queue_receiverorget_subscription_receivermethod off of aServiceBusClientinstance as seenhere.ServiceBusMessage: When sending, this is the type you will construct to contain your payload.  When receiving, this is where you will access the payload.Thread safetyWe do not guarantee that the ServiceBusClient, ServiceBusSender, and ServiceBusReceiver are thread-safe. We do not recommend reusing these instances across threads. It is up to the running application to use these classes in a thread-safe manner.ExamplesThe following sections provide several code snippets covering some of the most common Service Bus tasks, including:Send messages to a queueReceive messages from a queueSend and receive a message from a session enabled queueWorking with topics and subscriptionsSettle a message after receiptAutomatically renew Message or Session locksTo perform management tasks such as creating and deleting queues/topics/subscriptions, please utilize the azure-mgmt-servicebus library, availablehere.Please find further examples in thesamplesdirectory demonstrating common Service Bus scenarios such as sending, receiving, session management and message handling.Send messages to a queueNOTE:see reference documentationhere.This example sends single message and array of messages to a queue that is assumed to already exist, created via the Azure portal or az commands.fromazure.servicebusimportServiceBusClient,ServiceBusMessageimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_sender(queue_name)assender:# Sending a single messagesingle_message=ServiceBusMessage("Single message")sender.send_messages(single_message)# Sending a list of messagesmessages=[ServiceBusMessage("First message"),ServiceBusMessage("Second message")]sender.send_messages(messages)NOTE:A message may be scheduled for delayed delivery using theServiceBusSender.schedule_messages()method, or by specifyingServiceBusMessage.scheduled_enqueue_time_utcbefore callingServiceBusSender.send_messages()For more detail on scheduling and schedule cancellation please see a samplehere.Receive messages from a queueTo receive from a queue, you can either perform an ad-hoc receive viareceiver.receive_messages()or receive persistently through the receiver itself.Receive messages from a queue through iterating over ServiceBusReceiverfromazure.servicebusimportServiceBusClientimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:# max_wait_time specifies how long the receiver should wait with no incoming messages before stopping receipt.# Default is None; to receive forever.withclient.get_queue_receiver(queue_name,max_wait_time=30)asreceiver:formsginreceiver:# ServiceBusReceiver instance is a generator.print(str(msg))# If it is desired to halt receiving early, one can break out of the loop here safely.NOTE:Any message received withreceive_mode=PEEK_LOCK(this is the default, with the alternative RECEIVE_AND_DELETE removing the message from the queue immediately on receipt)
has a lock that must be renewed viareceiver.renew_message_lockbefore it expires if processing would take longer than the lock duration.
SeeAutoLockRenewerfor a helper to perform this in the background automatically.
Lock duration is set in Azure on the queue or topic itself.Receive messages from a queue through ServiceBusReceiver.receive_messages()NOTE:ServiceBusReceiver.receive_messages()receives a single or constrained list of messages through an ad-hoc method call, as opposed to receiving perpetually from the generator. It always returns a list.fromazure.servicebusimportServiceBusClientimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(queue_name)asreceiver:received_message_array=receiver.receive_messages(max_wait_time=10)# try to receive a single message within 10 secondsifreceived_message_array:print(str(received_message_array[0]))withclient.get_queue_receiver(queue_name)asreceiver:received_message_array=receiver.receive_messages(max_message_count=5,max_wait_time=10)# try to receive maximum 5 messages in a batch within 10 secondsformessageinreceived_message_array:print(str(message))In this example, max_message_count declares the maximum number of messages to attempt receiving before hitting a max_wait_time as specified in seconds.NOTE:It should also be noted thatServiceBusReceiver.peek_messages()is subtly different than receiving, as it does not lock the messages being peeked, and thus they cannot be settled.Send and receive a message from a session enabled queueNOTE:see reference documentation for sessionsendandreceive.Sessions provide first-in-first-out and single-receiver semantics on top of a queue or subscription.  While the actual receive syntax is the same, initialization differs slightly.fromazure.servicebusimportServiceBusClient,ServiceBusMessageimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_SESSION_QUEUE_NAME']session_id=os.environ['SERVICE_BUS_SESSION_ID']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_sender(queue_name)assender:sender.send_messages(ServiceBusMessage("Session Enabled Message",session_id=session_id))# If session_id is null here, will receive from the first available session.withclient.get_queue_receiver(queue_name,session_id=session_id)asreceiver:formsginreceiver:print(str(msg))NOTE: Messages received from a session do not need their locks renewed like a non-session receiver; instead the lock management occurs at the
session level with a session lock that may be renewed withreceiver.session.renew_lock()Working withtopicsandsubscriptionsNOTE:see reference documentation fortopicsandsubscriptions.Topics and subscriptions give an alternative to queues for sending and receiving messages.  See documentsherefor more overarching detail,
and of how these differ from queues.fromazure.servicebusimportServiceBusClient,ServiceBusMessageimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']topic_name=os.environ['SERVICE_BUS_TOPIC_NAME']subscription_name=os.environ['SERVICE_BUS_SUBSCRIPTION_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_topic_sender(topic_name)assender:sender.send_messages(ServiceBusMessage("Data"))# If session_id is null here, will receive from the first available session.withclient.get_subscription_receiver(topic_name,subscription_name)asreceiver:formsginreceiver:print(str(msg))Settle a message after receiptWhen receiving from a queue, you have multiple actions you can take on the messages you receive.NOTE: You can only settleServiceBusReceivedMessageobjects which are received inServiceBusReceiveMode.PEEK_LOCKmode (this is the default).ServiceBusReceiveMode.RECEIVE_AND_DELETEmode removes the message from the queue on receipt.ServiceBusReceivedMessagemessages
returned frompeek_messages()cannot be settled, as the message lock is not taken like it is in the aforementioned receive methods.If the message has a lock as mentioned above, settlement will fail if the message lock has expired.
If processing would take longer than the lock duration, it must be maintained viareceiver.renew_message_lockbefore it expires.
Lock duration is set in Azure on the queue or topic itself.
SeeAutoLockRenewerfor a helper to perform this in the background automatically.CompleteDeclares the message processing to be successfully completed, removing the message from the queue.fromazure.servicebusimportServiceBusClientimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(queue_name)asreceiver:formsginreceiver:print(str(msg))receiver.complete_message(msg)AbandonAbandon processing of the message for the time being, returning the message immediately back to the queue to be picked up by another (or the same) receiver.fromazure.servicebusimportServiceBusClientimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(queue_name)asreceiver:formsginreceiver:print(str(msg))receiver.abandon_message(msg)DeadLetterTransfer the message from the primary queue into a special "dead-letter sub-queue" where it can be accessed using theServiceBusClient.get_<queue|subscription>_receiverfunction with parametersub_queue=ServiceBusSubQueue.DEAD_LETTERand consumed from like any other receiver. (see samplehere)fromazure.servicebusimportServiceBusClientimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(queue_name)asreceiver:formsginreceiver:print(str(msg))receiver.dead_letter_message(msg)DeferDefer is subtly different from the prior settlement methods.  It prevents the message from being directly received from the queue
by setting it aside such that it must be received by sequence number in a call toServiceBusReceiver.receive_deferred_messages(see samplehere)fromazure.servicebusimportServiceBusClientimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(queue_name)asreceiver:formsginreceiver:print(str(msg))receiver.defer_message(msg)Automatically renew Message or Session locksNOTE:see reference documentation forauto-lock-renewal.AutoLockReneweris a simple method for ensuring your message or session remains locked even over long periods of time, if callingreceiver.renew_message_lock/receiver.session.renew_lockis impractical or undesired.
Internally, it is not much more than shorthand for creating a concurrent watchdog to do lock renewal if the object is nearing expiry.
It should be used as follows:Message lock automatic renewingfromazure.servicebusimportServiceBusClient,AutoLockRenewerimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']queue_name=os.environ['SERVICE_BUS_QUEUE_NAME']# Can also be called via "with AutoLockRenewer() as renewer" to automate closing.renewer=AutoLockRenewer()withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(queue_name)asreceiver:formsginreceiver.receive_messages():renewer.register(receiver,msg,max_lock_renewal_duration=60)# Do your application logic herereceiver.complete_message(msg)renewer.close()Session lock automatic renewingfromazure.servicebusimportServiceBusClient,AutoLockRenewerimportosconnstr=os.environ['SERVICE_BUS_CONNECTION_STR']session_queue_name=os.environ['SERVICE_BUS_SESSION_QUEUE_NAME']session_id=os.environ['SERVICE_BUS_SESSION_ID']# Can also be called via "with AutoLockRenewer() as renewer" to automate closing.renewer=AutoLockRenewer()withServiceBusClient.from_connection_string(connstr)asclient:withclient.get_queue_receiver(session_queue_name,session_id=session_id)asreceiver:renewer.register(receiver,receiver.session,max_lock_renewal_duration=300)# Duration for how long to maintain the lock for, in seconds.formsginreceiver.receive_messages():# Do your application logic herereceiver.complete_message(msg)renewer.close()If for any reason auto-renewal has been interrupted or failed, this can be observed via theauto_renew_errorproperty on the object being renewed, or by having passed a callback to theon_lock_renew_failureparameter on renewer initialization.
It would also manifest when trying to take action (such as completing a message) on the specified object.TroubleshootingLoggingEnableazure.servicebuslogger to collect traces from the library.Enableuamqplogger to collect traces from the underlying uAMQP library.Enable AMQP frame level trace by settinglogging_enable=Truewhen creating the client.There may be cases where you consider theuamqplogging to be too verbose. To suppress unnecessary logging, add the following snippet to the top of your code:importlogging# The logging levels below may need to be changed based on the logging that you want to suppress.uamqp_logger=logging.getLogger('uamqp')uamqp_logger.setLevel(logging.ERROR)# or even further fine-grained control, suppressing the warnings in uamqp.connection moduleuamqp_connection_logger=logging.getLogger('uamqp.connection')uamqp_connection_logger.setLevel(logging.ERROR)TimeoutsThere are various timeouts a user should be aware of within the library.10 minute service side link closure:  A link, once opened, will be closed after 10 minutes idle to protect the service against resource leakage.  This should largely
be transparent to a user, but if you notice a reconnect occurring after such a duration, this is why.  Performing any operations, including management operations, on the
link will extend this timeout.max_wait_time: Provided on creation of a receiver or when callingreceive_messages(), the time after which receiving messages will halt after no traffic.  This applies both to the imperativereceive_messages()function as well as the length
a generator-style receive will run for before exiting if there are no messages.  Passing None (default) will wait forever, up until the 10 minute threshold if no other action is taken.NOTE:If processing of a message or session is sufficiently long as to cause timeouts, as an alternative to callingreceiver.renew_message_lock/receiver.session.renew_lockmanually, one can
leverage theAutoLockRenewerfunctionality detailedabove.Common ExceptionsThe Service Bus APIs generate the following exceptions in azure.servicebus.exceptions:ServiceBusConnectionError:An error occurred in the connection to the service.
This may have been caused by a transient network issue or service problem. It is recommended to retry.ServiceBusAuthorizationError:An error occurred when authorizing the connection to the service.
This may have been caused by the credentials not having the right permission to perform the operation.
It is recommended to check the permission of the credentials.ServiceBusAuthenticationError:An error occurred when authenticate the connection to the service.
This may have been caused by the credentials being incorrect. It is recommended to check the credentials.OperationTimeoutError:This indicates that the service did not respond to an operation within the expected amount of time.
This may have been caused by a transient network issue or service problem. The service may or may not have successfully completed the request; the status is not known.
It is recommended to attempt to verify the current state and retry if necessary.MessageSizeExceededError:This indicate that the message content is larger than the service bus frame size.
This could happen when too many service bus messages are sent in a batch or the content passed into
the body of aMessageis too large. It is recommended to reduce the count of messages being sent in a batch or the size of content being passed into a singleServiceBusMessage.MessageAlreadySettled:This indicates failure to settle the message.
This could happen when trying to settle an already-settled message.MessageLockLostError:The lock on the message has expired and it has been released back to the queue.
It will need to be received again in order to settle it.
You should be aware of the lock duration of a message and keep renewing the lock before expiration in case of long processing time.AutoLockRenewercould help on keeping the lock of the message automatically renewed.SessionLockLostError:The lock on the session has expired.
All unsettled messages that have been received can no longer be settled.
It is recommended to reconnect to the session if receive messages again if necessary.
You should be aware of the lock duration of a session and keep renewing the lock before expiration in case of long processing time.AutoLockRenewercould help on keeping the lock of the session automatically renewed.MessageNotFoundError:Attempt to receive a message with a particular sequence number. This message isn't found.
Make sure the message hasn't been received already. Check the deadletter queue to see if the message has been deadlettered.MessagingEntityNotFoundError:Entity associated with the operation doesn't exist or it has been deleted.
Please make sure the entity exists.MessagingEntityDisabledError:Request for a runtime operation on a disabled entity. Please Activate the entity.ServiceBusQuotaExceededError:The messaging entity has reached its maximum allowable size, or the maximum number of connections to a namespace has been exceeded.
Create space in the entity by receiving messages from the entity or its subqueues.ServiceBusServerBusyError:Service isn't able to process the request at this time. Client can wait for a period of time, then retry the operation.ServiceBusCommunicationError:Client isn't able to establish a connection to Service Bus.
Make sure the supplied host name is correct and the host is reachable.
If your code runs in an environment with a firewall/proxy, ensure that the traffic to the Service Bus domain/IP address and ports isn't blocked.SessionCannotBeLockedError:Attempt to connect to a session with a specific session ID, but the session is currently locked by another client.
Make sure the session is unlocked by other clients.AutoLockRenewFailed:An attempt to renew a lock on a message or session in the background has failed.
This could happen when the receiver used byAutoLockReneweris closed or the lock of the renewable has expired.
It is recommended to re-register the renewable message or session by receiving the message or connect to the sessionful entity again.AutoLockRenewTimeout:The time allocated to renew the message or session lock has elapsed. You could re-register the object that wants be auto lock renewed or extend the timeout in advance.ServiceBusError:All other Service Bus related errors. It is the root error class of all the errors described above.Please view theexceptions reference docsfor detailed descriptions of our common Exception types.Next stepsMore sample codePlease find further examples in thesamplesdirectory demonstrating common Service Bus scenarios such as sending, receiving, session management and message handling.Additional documentationFor more extensive documentation on the Service Bus service, see theService Bus documentationon docs.microsoft.com.Management capabilities and documentationFor users seeking to perform management operations against ServiceBus (Creating a queue/topic/etc, altering filter rules, enumerating entities)
please see theazure-mgmt-servicebus documentationfor API documentation.  Terse usage examples can be foundhereas well.Pure Python AMQP Transport and Backward Compatibility SupportThe Azure Service Bus client library is now based on a pure Python AMQP implementation.uAMQPhas been removed as required dependency.To useuAMQPas the underlying transport:Installuamqpwith pip.$ pip install uamqpPassuamqp_transport=Trueduring client construction.fromazure.servicebusimportServiceBusClientconnection_str='<< CONNECTION STRING FOR THE SERVICE BUS NAMESPACE >>'queue_name='<< NAME OF THE QUEUE >>'client=ServiceBusClient.from_connection_string(connection_str,uamqp_transport=True)Note: Themessageattribute onServiceBusMessage/ServiceBusMessageBatch/ServiceBusReceivedMessage, which previously exposed theuamqp.Message, has been deprecated.
The "Legacy" objects returned bymessageattribute have been introduced to help facilitate the transition.Building uAMQP wheel from sourceazure-servicebusdepends on theuAMQPfor the AMQP protocol implementation.
uAMQP wheels are provided for most major operating systems and will be installed automatically when installingazure-servicebus.
IfuAMQPis intended to be used as the underlying AMQP protocol implementation forazure-servicebus,
uAMQP wheels can be found for most major operating systems.If you're running on a platform for which uAMQP wheels are not provided, please follow
If you intend to useuAMQPand you're running on a platform for which uAMQP wheels are not provided, please follow
theuAMQP Installationguidance to install from source.ContributingThis project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visithttps://cla.microsoft.com.When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.This project has adopted theMicrosoft Open Source Code of Conduct.
For more information see theCode of Conduct FAQor
contactopencode@microsoft.comwith any additional questions or comments.Release History7.11.4 (2023-11-13)Bugs FixedFixed a bug where a two character count session id was being incorrectly parsed by azure amqp.7.11.3 (2023-10-11)Bugs FixedFixed a bug whereprefetch_countwas not being passed through correctly and caused messages to not be received as expected when inRECEIVE_AND_DELETEmode (#31712,#31711).7.11.2 (2023-09-13)Bugs FixedFixed the errorNoneType object has no attribute 'settle_messages'which was raised when a connection was dropped due to a blocked process (#30514)Other ChangesThe__contains__method was added toazure.servicebusfor the following (PR #30846, thanks @pamelafox).ServiceBusConnectionStringPropertiesamqp.AmqpMessageHeaderamqp.AmqpMessagePropertiesmanagement.AccessRightsmanagement.NamespacePropertiesmanagement.QueuePropertiesmanagement.TopicPropertiesmanagement.SubscriptionPropertiesmanagement.RuleProperties7.11.1 (2023-07-12)Bugs FixedFixed the errorend frame received on invalid channelwhich was raised when a disconnect was sent by the service (#30860)Fixed the errorlink already closedwhich was raised when the client was closing and disconnecting from the service (#30836)Other ChangesThe error raised when attempting to complete a message with an expired lock received from a non-sessionful entity has been updated to the more fine-grainedMessageLockLostErrorfrom the superclassServiceBusError.7.11.0 (2023-06-12)Features AddedA new float keyword argumentsocket_timeouthas been added toget_queue_sender,get_queue_receiver,get_topic_sender, andget_subscription_receiveron the sync and asyncServiceBusClient.Bugs FixedFixed a bug where sending large messages failed on socket write timeout (#30425).Fixed a bug where settling large messages failed due todelivery_idbeingNone.Other ChangesTracing updates:Span links on receive/send spans now fall back to usingDiagnostic-Idif thetraceparentmessage application property is not found.Span links will now still be created for receive/send spans even if no context propagation headers are found in message application properties.Thecomponentattribute was removed from all spans.7.10.0 (2023-05-09)Version 7.10.0 is our first stable release of the Azure Service Bus client library based on a pure Python implemented AMQP stack.Features AddedA new boolean keyword argumentuamqp_transporthas been added to sync and asyncServiceBusClientconstructors which indicates whether to use theuamqplibrary or the default pure Python AMQP library as the underlying transport.Breaking ChangesAdded the following as dependencies to be used for operations over websocket:websocket-clientfor syncaiohttpfor asyncRemoved uAMQP from required dependencies and added it as an optional dependency for use with theuamqp_transportkeyword.Bugs FixedFixed a bug where sync and asyncServiceBusAdministrationClientexpectedcredentialwithget_tokenmethod returningAccessToken.tokenof typebytesand notstr, now matching the documentation.Fixed a bug whereraw_amqp_message.headerandmessage.headerproperties onServiceReceivedBusMessagewere returned withdurable,first_acquirer, andpriorityproperties set by default, rather than the values returned by the service.Fixed a bug whereServiceBusReceivedMessagewas not picklable (Issue #27947).Other ChangesThemessageattribute onServiceBus/ServiceBusMessageBatch/ServiceBusReceivedMessage, which previously exposed theuamqp.Message/uamqp.BatchMessage, has been deprecated.LegacyMessage/LegacyBatchMessageobjects returned by themessageattribute onServiceBus/ServiceBusMessageBatchhave been introduced to help facilitate the transition.Removed uAMQP from required dependencies.Addinguamqp >= 1.6.3as an optional dependency for use with theuamqp_transportkeyword.Updated tracing (#29995):Additional attributes added to existing spans:messaging.system- messaging system (i.e.,servicebus)messaging.operation- type of operation (i.e.,publish,receive, orsettle)messaging.batch.message_count- number of messages sent or received (if more than one)A span will now be created upon calls to the service that settle messages.The span name will contain the settlement operation (e.g.,ServiceBus.complete)The span will containaz.namespace,messaging.destination.name,net.peer.name,messaging.system, andmessaging.operationattributes.Allsendspans now contain links tomessagespans. Now,messagespans will no longer contain a link to thesendspan.7.10.0b1 (2023-04-13)Features AddedA new boolean keyword argumentuamqp_transporthas been added to sync and asyncServiceBusClientconstructors which indicates whether to use theuamqplibrary or the default pure Python AMQP library as the underlying transport.Bugs FixedFixed a bug where sync and asyncServiceBusAdministrationClientexpectedcredentialwithget_tokenmethod returningAccessToken.tokenof typebytesand notstr, now matching the documentation.Fixed a bug whereraw_amqp_message.headerandmessage.headerproperties onServiceReceivedBusMessagewere returned withdurable,first_acquirer, andpriorityproperties set by default, rather than the values returned by the service.Other ChangesThemessageattribute onServiceBus/ServiceBusMessageBatch/ServiceBusReceivedMessage, which previously exposed theuamqp.Message/uamqp.BatchMessage, has been deprecated.LegacyMessage/LegacyBatchMessageobjects returned by themessageattribute onServiceBus/ServiceBusMessageBatchhave been introduced to help facilitate the transition.Removed uAMQP from required dependencies.Addinguamqp >= 1.6.3as an optional dependency for use with theuamqp_transportkeyword.7.9.0 (2023-04-11)Breaking ChangesClient side validation of input is now disabled by default for the sync and asyncServiceBusAdministrationClient. This means there will be nomsrest.exceptions.ValidationErrorraised by theServiceBusAdministrationClientin the case of malformed input. Anazure.core.exceptions.HttpResponseErrormay now be raised if the server refuses the request.Bugs FixedFixed a bug where enum members inazure.servicebus.managementwere not following uppercase convention.Other ChangesAll pure Python AMQP stack related changes have been removed and will be added back in the next version.Updated minimumazure-coreversion to 1.24.0.Removedmsrestdependency.Removedazure-commondependency.7.9.0b1 (2023-03-09)Features AddedIterator receiving from Service Bus entities has been added back in.7.8.3 (2023-03-09)Bugs FixedFixed a bug where asynchronous method to add distributed tracing attributes was not being awaited (Issue #28738).7.8.2 (2023-01-10)Bugs FixedFixed a bug that would cause an exception whenNonewas sent toset_stateinstead of clearing session state (Issue #27582).Other ChangesUpdated uAMQP dependency to 1.6.3.Added support for Python 3.11.7.9.0a1 (2022-10-11)Version 7.9.0a1 is our first efforts to build an Azure Service Bus client library based on a pure Python implemented AMQP stack.Breaking ChangesThe following features have been temporarily pulled out which will be added back in future previews as we work towards a stable release:Iterator receiving from Service Bus entities.Other ChangesuAMQP dependency is removed.7.8.1 (2022-10-11)This version and all future versions will require Python 3.7+. Python 3.6 is no longer supported.Bugs FixedFixed bug on asyncServiceBusClientwherecustom_endpoint_addressandconnection_verifykwargs were not being passed through correctly. (Issue #26015)7.8.0 (2022-07-06)This version will be the last version to officially support Python 3.6, future versions will require Python 3.7+.Features AddedInServiceBusClient,get_queue_receiver,get_subscription_receiver,get_queue_sender, andget_topic_sendernow accept
an optionalclient_identifierargument which allows for specifying a custom identifier for the respective sender or receiver. It can
be useful during debugging as Service Bus associates the id with errors and helps with easier correlation.ServiceBusReceiverandServiceBusSenderhave an added propertyclient_identifierwhich returns theclient_identifierfor the current instance.7.7.0 (2022-06-07)Bugs FixedFixed bug to make AMQP exceptions retryable by default, if condition is not non-retryable, to ensure that InternalServerErrors are retried.Features AddedTheServiceBusClientconstructor now accepts optionalcustom_endpoint_addressargument
which allows for specifying a custom endpoint to use when communicating with the Service Bus service,
and is useful when your network does not allow communicating to the standard Service Bus endpoint.TheServiceBusClientconstructor now accepts optionalconnection_verifyargument
which allows for specifying the path to the custom CA_BUNDLE file of the SSL certificate which is used to authenticate
the identity of the connection endpoint.7.6.1 (2022-04-11)Other ChangesImproved receiving by releasing messages from internal buffer when theprefetch_countofServiceBusReceiveris set 0 and there is no active receive call, this helps avoid receiving expired messages and incrementing delivery count of a message.7.6.0 (2022-02-10)Features AddedIntroduceServiceBusMessageStateenum that can assume the values ofactive,scheduledordeferred.Addstateproperty inServiceBusReceivedMessage.7.5.0 (2022-01-12)This version and all future versions will require Python 3.6+. Python 2.7 is no longer supported.Features AddedAdded support for fixed (linear) retry backoff:Sync/asyncServiceBusClientconstructors andfrom_connection_stringtakeretry_modeas a keyword argument.Added new enum classServiceBusSessionFilter, which is the type of existingNEXT_AVAILABLE_SESSIONvalue.Bugs FixedFixed bug that when settingServiceBusMessage.time_to_livewith value beingdatetime.timedelta,total_secondsshould be respected (PR #21869, thanks @jyggen).Other ChangesImproved token refresh timing to prevent potentially blocking main flow when the token is about to get expired soon.Updated uAMQP dependency to 1.5.1.7.4.0 (2021-11-09)Features AddedGA the support to create and update queues and topics of large message size toServiceBusAdministrationClient. This feature is only available for Service Bus of Premium Tier.Methodscreate_queue,create_topic,update_queue,update_topiconServiceBusAdministrationClientnow take a new keyword argumentmax_message_size_in_kilobytes.QueuePropertiesandTopicPropertiesnow have a new instance variablemax_message_size_in_kilobytes.The constructor ofServiceBusAdministrationClientas well asServiceBusAdministrationClient.from_connection_stringnow take keyword argumentapi_versionto configure the Service Bus API version. Supported service versions are "2021-05" and "2017-04".Added new enum classazure.servicebus.management.ApiVersionto represent the supported Service Bus API versions.Bugs FixedFixed bug thatServiceBusReceivercan not connect to sessionful entity with session id being empty string.Fixed bug thatServiceBusMessage.partition_keycan not parse empty string properly.7.4.0b1 (2021-10-06)Features AddedAdded support to create and update queues and topics of large message size toServiceBusAdministrationClient. This feature is only available for Service Bus of Premium Tier.Methodscreate_queue,create_topic,update_queue,update_topiconServiceBusAdministrationClientnow take a new keyword argumentmax_message_size_in_kilobytes.QueuePropertiesandTopicPropertiesnow have a new instance variablemax_message_size_in_kilobytes.7.3.4 (2021-10-06)Other ChangesUpdated uAMQP dependency to 1.4.3.Added support for Python 3.10.Fixed memory leak in win32 socketio and tlsio (issue #19777).Fixed memory leak in the process of converting AMQPValue into string (issue #19777).7.3.3 (2021-09-08)Bugs FixedImproved memory usage ofServiceBusClientto automatically discard spawnedServiceBusSenderorServiceBusReceiverfrom its handler set when no strong reference to the sender or receiver exists anymore.Reduced CPU load ofazure.servicebus.AutoLockRenewerduring lock renewal.7.3.2 (2021-08-10)Bugs FixedFixed a bug thatazure.servicebus.aio.AutoLockRenewercrashes on disposal if no messages have been registered (#19642).Fixed a bug thatazure.servicebus.AutoLockReneweronly supports auto lock renewal formax_workersamount of messages/sessions at a time (#19362).7.3.1 (2021-07-07)FixedFixed a bug that when settingServiceBusMessage.partition_key, input value should be not validated againstsession_idof None (PR #19233, thanks @bishnu-shb).Fixed a bug that settingServiceBusMessage.time_to_livecauses OverflowError error on Ubuntu 20.04.Fixed a bug thatAmqpAnnotatedProperties.creation_timeandAmqpAnnotatedProperties.absolute_expiry_timeshould be calculated in the unit of milliseconds instead of seconds.Updated uAMQP dependency to 1.4.1.Fixed a bug that attributes creation_time, absolute_expiry_time and group_sequence on MessageProperties should be compatible with integer types on Python 2.7.7.3.0 (2021-06-08)New FeaturesSupport for sending AMQP annotated message which allows full access to the AMQP message fields is now GA.Introduced new namespaceazure.servicebus.amqp.Introduced new classesazure.servicebus.amqp.AmqpMessageHeaderandazure.servicebus.amqp.AmqpMessagePropertiesfor accessing amqp header and properties.Breaking Changes from 7.2.0b1Renamed and movedazure.servicebus.AMQPAnnotatedMessagetoazure.servicebus.amqp.AmqpAnnotatedMessage.Renamed and movedazure.servicebus.AMQPMessageBodyTypetoazure.servicebus.amqp.AmqpMessageBodyType.AmqpAnnotatedMessage.headerreturnsazure.servicebus.amqp.AmqpMessageHeaderinstead ofuamqp.message.MessageHeader.AmqpAnnotatedMessage.propertiesreturnsazure.servicebus.amqp.AmqpMessagePropertiesinstead ofuamqp.message.MessageProperties.raw_amqp_messageonServiceBusMessageandServiceBusReceivedMessageis now a read-only property instead of an instance variable.Bug FixesFixed a bug thatServiceBusReceiveriterator stops iteration after recovery from connection error (#18795).7.2.0 (2021-05-13)The preview features related to AMQPAnnotatedMessage introduced in 7.2.0b1 are not included in this version.New FeaturesAdded support for usingazure.core.credentials.AzureNamedKeyCredentialas credential for authenticating the clients.Support for usingazure.core.credentials.AzureSasCredentialas credential for authenticating the clients is now GA.ServiceBusAdministrationClient.update_*methods now accept keyword arguments to override the properties specified in the model instance.Bug FixesFixed a bug whereupdate_queueandupdate_subscriptionmethods were mutating the propertiesforward_toandforward_dead_lettered_messages_toof the model instance when those properties are entities instead of full paths.Improved therepronServiceBusMessageandServiceBusReceivedMessageto show more meaningful text.Updated uAMQP dependency to 1.4.0.Fixed memory leaks in the process of link attach where source and target cython objects are not properly deallocated (#15747).Improved management operation callback not to parse description value of non AMQP_TYPE_STRING type as string (#18361).NotesUpdated azure-core dependency to 1.14.0.7.2.0b1 (2021-04-07)New FeaturesAdded support for usingazure.core.credentials.AzureSasCredentialas credential for authenticating the clients.Added support for sending AMQP annotated message which allows full access to the AMQP message fields.
-azure.servicebus.AMQPAnnotatedMessageis now made public and could be instantiated for sending.Added new enum classazure.servicebus.AMQPMessageBodyTypeto represent the body type of the message message which includes:DATA: The body of message consists of one or more data sections and each section contains opaque binary data.SEQUENCE: The body of message consists of one or more sequence sections and each section contains an arbitrary number of structured data elements.VALUE: The body of message consists of one amqp-value section and the section contains a single AMQP value.Added new propertybody_typeonazure.servicebus.ServiceBusMessageandazure.servicebus.ReceivedMessagewhich returnsazure.servicebus.AMQPMessageBodyType.7.1.1 (2021-04-07)This version and all future versions will require Python 2.7 or Python 3.6+, Python 3.5 is no longer supported.New FeaturesUpdatedforward_toandforward_dead_lettered_messages_toparameters increate_queue,update_queue,create_subscription, andupdate_subscriptionmethods on sync and asyncServiceBusAdministrationClientto accept entities as well, rather than only full paths. In the case that an entity is passed in, it is assumed that the entity exists within the same namespace used for constructing theServiceBusAdministrationClient.Bug FixesUpdated uAMQP dependency to 1.3.0.Fixed bug that sending message of large size triggering segmentation fault when the underlying socket connection is lost (#13739, #14543).Fixed bug in link flow control where link credit and delivery count should be calculated based on per message instead of per transfer frame (#16934).7.1.0 (2021-03-09)This version will be the last version to officially support Python 3.5, future versions will require Python 2.7 or Python 3.6+.New FeaturesUpdated the following methods so that lists and single instances of Mapping representations are accepted for corresponding strongly-typed object arguments (PR #14807, thanks @bradleydamato):update_queue,update_topic,update_subscription, andupdate_ruleonServiceBusAdministrationClientaccept Mapping representations ofQueueProperties,TopicProperties,SubscriptionProperties, andRuleProperties, respectively.send_messagesandschedule_messageson both sync and async versions ofServiceBusSenderaccept a list of or single instance of Mapping representations ofServiceBusMessage.add_messageonServiceBusMessageBatchnow accepts a Mapping representation ofServiceBusMessage.BugFixesOperations failing due touamqp.errors.LinkForceDetachcaused by no activity on the connection for 10 minutes will now be retried internally except for the session receiver case.uamqp.errors.AMQPConnectionErrorerrors with condition codeamqp:unknown-errorare now categorized intoServiceBusConnectionErrorinstead of the generalServiceBusError.Theupdate_*methods onServiceBusManagementClientwill now raise aTypeErrorrather than anAttributeErrorin the case of unsupported input type.7.0.1 (2021-01-12)BugFixesforward_toandforward_dead_lettered_messages_towill no longer cause authorization errors when used inServiceBusAdministrationClientfor queues and subscriptions (#15543).Updated uAMQP dependency to 1.2.13.Fixed bug that macOS was unable to detect network error (#15473).Fixed bug thatuamqp.ReceiveClientanduamqp.ReceiveClientAsyncreceive messages during connection establishment (#15555).Fixed bug where connection establishment on macOS with Clang 12 triggering unrecognized selector exception (#15567).Fixed bug in accessing message properties triggering segmentation fault when the underlying C bytes are NULL (#15568).7.0.0 (2020-11-23)Note:This is the GA release of theazure-servicebuspackage, rolling out the official API surface area constructed over the prior preview releases.  Users migrating fromv0.50are advised to view themigration guide.New Featuressub_queueandreceive_modemay now be passed in as a valid string (as defined by their respective enum type) as well as their enum form when constructingServiceBusReceiver.Added support for Distributed Tracing of send, receive, and schedule scenarios.Breaking ChangesServiceBusSenderandServiceBusReceiverare no longer reusable and will raiseValueErrorwhen trying to operate on a closed handler.RenameReceiveModetoServiceBusReceiveModeandSubQueuetoServiceBusSubQueue, and convert their enum values from ints to human-readable strings.Rename enum valuesDeadLettertoDEAD_LETTER,TransferDeadLettertoTRANSFER_DEAD_LETTER,PeekLocktoPEEK_LOCKandReceiveAndDeletetoRECEIVE_AND_DELETEto conform to sdk guidelines going forward.send_messages,schedule_messages,cancel_scheduled_messagesandreceive_deferred_messagesnow performs a no-op rather than raising aValueErrorif provided an empty list of messages or an empty batch.ServiceBusMessage.amqp_annotated_messagehas been renamed toServiceBusMessage.raw_amqp_messageto normalize with other SDKs.Redesigned error hierarchy based on the service-defined error condition:MessageAlreadySettlednow inherits fromValueErrorinstead ofServiceBusMessageErroras it's a client-side validation.RemovedNoActiveSessionwhich is now replaced byOperationTimeoutErroras the client times out when trying to connect to any available session.RemovedServiceBusMessageErroras error condition based exceptions provide comprehensive error information.RemovedMessageSettleFailedas error condition based exceptions provide comprehensive error information.RemovedMessageSendFailedas error condition based exceptions provide comprehensive error information.RenamedMessageContentTooLargetoMessageSizeExceededErrorto be consistent with the term defined by the service.RenamedMessageLockExpiredtoMessageLockLostErrorto be consistent with the term defined by the service.RenamedSessionLockExpiredtoSessionLockLostErrorto be consistent with the term defined by the service.IntroducedMessageNotFoundErrorwhich would be raised when the requested message was not found.IntroducedMessagingEntityNotFoundErrorwhich would be raised when a Service Bus resource cannot be found by the Service Bus service.IntroducedMessagingEntityDisabledErrorwhich would be raised when the Messaging Entity is disabled.IntroducedMessagingEntityAlreadyExistsErrorwhich would be raised when an entity with the same name exists under the same namespace.IntroducedServiceBusQuotaExceededErrorwhich would be raised when a Service Bus resource has been exceeded while interacting with the Azure Service Bus service.IntroducedServiceBusServerBusyErrorwhich would be raised when the Azure Service Bus service reports that it is busy in response to a client request to perform an operation.IntroducedServiceBusCommunicationErrorwhich would be raised when there was a general communications error encountered when interacting with the Azure Service Bus service.IntroducedSessionCannotBeLockedErrorwhich would be raised when the requested session cannot be locked.Introduced new client side validation on certain use cases:ServiceBusMessagewill now raise aTypeErrorwhen provided an invalid body type.  Valid bodies are strings, bytes, and None.  Lists are no longer accepted, as they simply concatenated the contents prior.An improperreceive_modevalue will now raiseValueErrorinstead ofTypeErrorin line with supporting extensible enums.SettingServiceBusMessage.partition_keyto a value different thansession_idon the message instance now raisesValueError.ServiceBusClient.get_queue/topic_senderandServiceBusClient.get_queue/subscription_receiverwill now
raiseValueErrorif thequeue_nameortopic_namedoes not match theEntityPathin the connection string used to construct theServiceBusClient.Settling a message that has been peeked will raiseValueError.Settling a message or renewing a lock on a message received inRECEIVE_AND_DELETEreceive mode will raiseValueError.Settingsession_id,reply_to_session_id,message_idandpartition_keyonServiceBusMessagelonger than 128 characters will raiseValueError.ServiceBusReceiver.get_streaming_message_iterhas been made internal for the time being to assess use patterns before committing to back-compatibility; messages may still be iterated over in equivalent fashion by iterating on the receiver itself.BugFixesServiceBusAdministrationClient.create_ruleby default now creates aTrueRuleFilterrule.FQDNs and Connection strings are now supported even with strippable whitespace or protocol headers (e.g. 'sb://').Using parameterauto_lock_reneweron a sessionful receiver alongsideReceiveMode.ReceiveAndDeletewill no longer fail during receipt due to failure to register the message with the renewer.7.0.0b8 (2020-11-05)New FeaturesAdded support fortimeoutparameter on the following operations:ServiceBusSender:send_messages,schedule_messagesandcancel_scheduled_messagesServiceBusReceiver:receive_deferred_messages,peek_messagesandrenew_message_lockServiceBusSession:get_state,set_stateandrenew_lockazure.servicebus.exceptions.ServiceBusErrornow inherits fromazure.core.exceptions.AzureError.Added aparse_connection_stringmethod which parses a connection string into a properties bag containing its component partsAdd support forauto_lock_renewerparameter onget_queue_receiverandget_subscription_receivercalls to allow auto-registration of messages and sessions for auto-renewal.Breaking ChangesRenamedAutoLockRenewtoAutoLockRenewer.Removed classServiceBusSessionReceiverwhich is now unified within classServiceBusReceiver.Removed methodsServiceBusClient.get_queue_session_receiverandServiceBusClient.get_subscription_session_receiver.ServiceBusClient.get_queue_receiverandServiceBusClient.get_subscription_receivernow take keyword parametersession_idwhich must be set when getting a receiver for the sessionful entity.The parameterinner_exceptionthatServiceBusError.__init__takes is now renamed toerror.Renamedazure.servicebus.exceptions.MessageErrortoazure.servicebus.exceptions.ServiceBusMessageErrorRemoved errorazure.servicebus.exceptions.ServiceBusResourceNotFoundasazure.core.exceptions.ResourceNotFoundErroris now raised when a Service Bus
resource does not exist when using theServiceBusAdministrationClient.RenamedMessagetoServiceBusMessage.RenamedReceivedMessagetoServiceBusReceivedMessage.RenamedBatchMessagetoServiceBusMessageBatch.Renamed methodaddtoadd_messageon the class.Removed classPeekedMessage.Removed classReceivedMessageunder moduleazure.servicebus.aio.RenamedServiceBusSender.create_batchtoServiceBusSender.create_message_batch.ExceptionsMessageSendFailed,MessageSettleFailedandMessageLockExpirednow inherit fromazure.servicebus.exceptions.ServiceBusMessageError.get_stateinServiceBusSessionnow returnsbytesinstead of astring.ServiceBusReceiver.receive_messages/get_streaming_message_iterandServiceBusClient.get_<queue/subscription>_receivernow raises ValueError if the givenmax_wait_timeis less than or equal to 0.Message settlement methods are moved fromServiceBusMessagetoServiceBusReceiver:UseServiceBusReceiver.complete_messageinstead ofServiceBusReceivedMessage.completeto complete a message.UseServiceBusReceiver.abandon_messageinstead ofServiceBusReceivedMessage.abandonto abandon a message.UseServiceBusReceiver.defer_messageinstead ofServiceBusReceivedMessage.deferto defer a message.UseServiceBusReceiver.dead_letter_messageinstead ofServiceBusReceivedMessage.dead_letterto dead letter a message.Message settlement methods (complete_message,abandon_message,defer_messageanddead_letter_message)
and methods that use amqp management link for request likeschedule_messages,received_deferred_messages, etc.
now raise more concrete exception other thanMessageSettleFailedandServiceBusError.Messagerenew_lockmethod is moved fromServiceBusMessagetoServiceBusReceiver:ChangedServiceBusReceivedMessage.renew_locktoServiceBusReceiver.renew_message_lockAutoLockRenewer.registernow takesServiceBusReceiveras a positional parameter.Removedencodingsupport fromServiceBusMessage.ServiceBusMessage.amqp_messagehas been renamed toServiceBusMessage.amqp_annotated_messagefor cross-sdk consistency.Allnameparameters inServiceBusAdministrationClientare now precisely specified alaqueue_nameorrule_nameServiceBusMessage.via_partition_keyis no longer exposed, this is pending a full implementation of transactions as it has no external use. If needed, the underlying value can still be accessed inServiceBusMessage.amqp_annotated_message.annotations.ServiceBusMessage.propertieshas been renamed toServiceBusMessage.application_propertiesfor consistency with service verbiage.Sub-client (ServiceBusSenderandServiceBusReceiver)from_connection_stringinitializers have been made internal until needed. Clients should be initialized from rootServiceBusClient.ServiceBusMessage.labelhas been renamed toServiceBusMessage.subject.ServiceBusMessage.amqp_annotated_messagehas had its type renamed fromAMQPMessagetoAMQPAnnotatedMessageAutoLockRenewertimeoutparameter is renamed tomax_lock_renew_durationAttempting to autorenew a non-renewable message, such as one received inReceiveAndDeletemode, or configure auto-autorenewal on aReceiveAndDeletereceiver, will raise aValueError.The default value of parametermax_message_countonServiceBusReceiver.receive_messagesis now1instead ofNoneand will raise ValueError if the given value is less than or equal to 0.BugFixesUpdated uAMQP dependency to 1.2.12.Added support for Python 3.9.Fixed bug where amqp messagefooteranddelivery_annotationwere not encoded into the outgoing payload.7.0.0b7 (2020-10-05)Breaking ChangesPassing any type other thanReceiveModeas parameterreceive_modenow throws aTypeErrorinstead ofAttributeError.Administration Client calls now take only entity names, not<Entity>Descriptionsas well to reduce ambiguity in which entity was being acted on. TypeError will now be thrown on improper parameter types (non-string).AMQPMessage(Message.amqp_message) properties are now read-only, changes of these properties would not be reflected in the underlying message.  This may be subject to change before GA.7.0.0b6 (2020-09-10)New Featuresrenew_lock()now returns the UTC datetime that the lock is set to expire at.receive_deferred_messages()can now take a single sequence number as well as a list of sequence numbers.Messages can now be sent twice in succession.Connection strings used withfrom_connection_stringmethods now support using theSharedAccessSignaturekey in leiu ofsharedaccesskeyandsharedaccesskeyname, taking the string of the properly constructed token as value.Internal AMQP message properties (header, footer, annotations, properties, etc) are now exposed viaMessage.amqp_messageBreaking ChangesRenamedprefetchtoprefetch_count.RenamedReceiveSettleModeenum toReceiveMode, and respectively themodeparameter toreceive_mode.retry_total,retry_backoff_factorandretry_backoff_maxare now defined at theServiceBusClientlevel and inherited by senders and receivers created from it.No longer exportNEXT_AVAILABLEinazure.servicebusmodule.  A nullsession_idwill suffice.Renamed parametermessage_counttomax_message_countas fewer messages may be present for methodpeek_messages()andreceive_messages().RenamedPeekMessagetoPeekedMessage.Renamedget_session_state()andset_session_state()toget_state()andset_state()accordingly.Renamed parameterdescriptiontoerror_descriptionfor methoddead_letter().Renamed propertiescreated_timeandmodified_timetocreated_at_utcandmodified_at_utcwithinAuthorizationRuleandNamespaceProperties.Removed parameterrequires_preprocessingfromSqlRuleFilterandSqlRuleAction.Removed propertynamespace_typefromNamespaceProperties.RenameServiceBusManagementClienttoServiceBusAdministrationClientAttempting to callsend_messageson something not aMessage,BatchMessage, or list ofMessages, will now throw aTypeErrorinstead ofValueErrorSending a message twice will no longer result in a MessageAlreadySettled exception.ServiceBusClient.close()now closes spawned senders and receivers.Attempting to initialize a sender or receiver with a different connection string entity and specified entity (e.g.queue_name) will result in an AuthenticationErrorRemoveis_anonymous_accessiblefrom management entities.Removesupport_orderingfromcreate_queueandQueuePropertiesRemoveenable_subscription_partitioningfromcreate_topicandTopicPropertiesget_dead_letter_[queue,subscription]_receiver()has been removed.  To connect to a dead letter queue, utilize thesub_queueparameter ofget_[queue,subscription]_receiver()provided with a value from theSubQueueenumNo longer exportServiceBusSharedKeyCredentialRenameentity_availability_statustoavailability_status7.0.0b5 (2020-08-10)New FeaturesAdded new properties to Message, PeekMessage and ReceivedMessage:content_type,correlation_id,label,message_id,reply_to,reply_to_session_idandto. Please refer to the docstring for further information.Added new properties to PeekMessage and ReceivedMessage:enqueued_sequence_number,dead_letter_error_description,dead_letter_reason,dead_letter_source,delivery_countandexpires_at_utc. Please refer to the docstring for further information.Added support for sending received messages viaServiceBusSender.send_messages.Addedon_lock_renew_failureas a parameter toAutoLockRenew.register, taking a callback for when the lock is lost non-intentially (e.g. not via settling, shutdown, or autolockrenew duration completion).Added new supported value types int, float, datetime and timedelta forCorrelationFilter.properties.Added new propertiesparametersandrequires_preprocessingtoSqlRuleFilterandSqlRuleAction.Added an explicit method to fetch the continuous receiving iterator,get_streaming_message_iter()such thatmax_wait_timecan be specified as an override.Breaking ChangesRemoved/Renamed several properties and instance variables on Message (the changes applied to the inherited Message type PeekMessage and ReceivedMessage).Renamed propertyuser_propertiestopropertiesThe original instance variablepropertieswhich represents the AMQP properties now becomes an internal instance variable_amqp_properties.Removed propertyenqueue_sequence_number.Removed propertyannotations.Removed instance variableheader.Removed several properties and instance variables on PeekMessage and ReceivedMessage.Removed propertypartition_idon both type.Removed propertysettledon both type.Removed instance variablereceived_timestamp_utcon both type.Removed propertysettledonPeekMessage.Removed propertyexpiredonReceivedMessage.AutoLockRenew.sleep_timeandAutoLockRenew.renew_periodhave been made internal as_sleep_timeand_renew_periodrespectively, as it is not expected a user will have to interact with them.AutoLockRenew.shutdownis nowAutoLockRenew.closeto normalize with other equivalent behaviors.RenamedQueueDescription,TopicDescription,SubscriptionDescriptionandRuleDescriptiontoQueueProperties,TopicProperties,SubscriptionProperties, andRuleProperties.RenamedQueueRuntimeInfo,TopicRuntimeInfo, andSubscriptionRuntimeInfotoQueueRuntimeProperties,TopicRuntimeProperties, andSubscriptionRuntimeProperties.Removed paramqueuefromcreate_queue,topicfromcreate_topic,subscriptionfromcreate_subscriptionandrulefromcreate_ruleofServiceBusManagementClient. Added paramnameto them and keyword arguments for queue properties, topic properties, subscription properties and rule properties.Removed model class attributes related keyword arguments fromupdate_queueandupdate_topicofServiceBusManagementClient. This is to encourage utilizing the model class instance instead as returned from a create_*, list_* or get_* operation to ensure it is properly populated.  Properties may still be modified.Model classesQueueProperties,TopicProperties,SubscriptionPropertiesandRulePropertiesrequire all arguments to be present for creation.  This is to protect against lack of partial updates by requiring all properties to be specified.Renamedidle_timeoutinget_<queue/subscription>_receiver()tomax_wait_timeto normalize with naming elsewhere.Updated uAMQP dependency to 1.2.10 such that the receiver does not shut down when generator times out, and can be received from again.7.0.0b4 (2020-07-06)New FeaturesAdded support for management of topics, subscriptions, and rules.receive_messages()(formerlyreceive()) now supports receiving a batch of messages (max_batch_size> 1) without the need to setprefetchparameter duringServiceBusReceiverinitialization.BugFixesFixed bug where syncAutoLockRenewdoes not shutdown itself timely.Fixed bug where asyncAutoLockRenewdoes not support context manager.Breaking ChangesRenamedreceive(),peek()schedule()andsend()toreceive_messages(),peek_messages(),schedule_messages()andsend_messages()to align with other service bus SDKs.receive_messages()(formerlyreceive()) no longer raises aValueErrorifmax_batch_sizeis less than theprefetchparameter set duringServiceBusReceiverinitialization.7.0.0b3 (2020-06-08)New FeaturesAdded support for management of queue entities.Useazure.servicebus.management.ServiceBusManagementClient(azure.servicebus.management.aio.ServiceBusManagementClientfor aio) to create, update, delete, list queues and get settings as well as runtime information of queues under a ServiceBus namespace.Added methodsget_queue_deadletter_receiverandget_subscription_deadletter_receiverinServiceBusClientto get aServiceBusReceiverfor the dead-letter sub-queue of the target entity.BugFixesUpdated uAMQP dependency to 1.2.8.Fixed bug where reason and description were not being set when dead-lettering messages.7.0.0b2 (2020-05-04)New FeaturesAdded methodget_topic_senderinServiceBusClientto get aServiceBusSenderfor a topic.Added methodget_subscription_receiverinServiceBusClientto get aServiceBusReceiverfor a subscription under specific topic.Added support for scheduling messages and scheduled message cancellation.UseServiceBusSender.schedule(messages, schedule_time_utc)for scheduling messages.UseServiceBusSender.cancel_scheduled_messages(sequence_numbers)for scheduled messages cancellation.ServiceBusSender.send()can now send a list of messages in one call, if they fit into a single batch.  If they do not fit aValueErroris thrown.BatchMessage.add()andServiceBusSender.send()would raiseMessageContentTooLargeif the content is over-sized.ServiceBusReceiver.receive()raisesValueErrorif its parammax_batch_sizeis greater than paramprefetchofServiceBusClient.Added exception classesMessageError,MessageContentTooLarge,ServiceBusAuthenticationError.MessageError: when you send a problematic message, such as an already sent message or an over-sized message.MessageContentTooLarge: when you send an over-sized message. A subclass ofValueErrorandMessageError.ServiceBusAuthenticationError: on failure to be authenticated by the service.Removed exception classInvalidHandlerState.BugFixesFixed bug where http_proxy and transport_type in ServiceBusClient are not propagated into Sender/Receiver creation properly.Updated uAMQP dependency to 1.2.7.Fixed bug in setting certificate of tlsio on MacOS. #7201Fixed bug that caused segmentation fault in network tracing on MacOS when settinglogging_enabletoTrueinServiceBusClient.Breaking ChangesSession receivers are now created via their own top level functions, e.g.get_queue_sesison_receiverandget_subscription_session_receiver.  Non session receivers no longer take session_id as a paramter.ServiceBusSender.send()no longer takes a timeout parameter, as it should be redundant with retry options provided when creating the client.Exception imports have been removed from moduleazure.servicebus. Import fromazure.servicebus.exceptionsinstead.ServiceBusSender.schedule()has swapped the ordering of parametersschedule_time_utcandmessagesfor better consistency withsend()syntax.7.0.0b1 (2020-04-06)Version 7.0.0b1 is a preview of our efforts to create a client library that is user friendly and idiomatic to the Python ecosystem. The reasons for most of the changes in this update can be found in the Azure SDK Design Guidelines for Python. For more information, please visithttps://aka.ms/azure-sdk-preview1-python.Note: Not all historical functionality exists in this version at this point.  Topics, Subscriptions, scheduling, dead_letter management and more will be added incrementally over upcoming preview releases.New FeaturesAdded new configuration parameters when creatingServiceBusClient.credential: The credential object used for authentication which implementsTokenCredentialinterface of getting tokens.http_proxy: A dictionary populated with proxy settings.For detailed information about configuration parameters, please see docstring inServiceBusClientand/or the reference documentation for more information.Added support for authentication using Azure Identity credentials.Added support for retry policy.Added support for http proxy.Manually callingreconnectshould no longer be necessary, it is now performed implicitly.Manually callingopenshould no longer be necessary, it is now performed implicitly.Note:close()-ing is still required if a context manager is not used, to avoid leaking connections.Added support for sending a batch of messages destined for heterogenous sessions.Breaking changesSimplified API and set of clientsget_queueno longer exists, utilizeget_queue_sender/receiverinstead.peekand otherqueue_clientfunctions have moved to their respective sender/receiver.Renamedfetch_nexttoreceive.Renamedsessiontosession_idto normalize naming when requesting a receiver against a given session.reconnectno longer exists, and is performed implicitly if needed.openno longer exists, and is performed implicitly if needed.Normalized top level client parameters with idiomatic and consistent naming.RenameddebuginServiceBusClientinitializer tologging_enable.Renamedservice_namespaceinServiceBusClientinitializer tofully_qualified_namespace.New error hierarchy, with more specific semanticsazure.servicebus.exceptions.ServiceBusErrorazure.servicebus.exceptions.ServiceBusConnectionErrorazure.servicebus.exceptions.ServiceBusResourceNotFoundazure.servicebus.exceptions.ServiceBusAuthorizationErrorazure.servicebus.exceptions.NoActiveSessionazure.servicebus.exceptions.OperationTimeoutErrorazure.servicebus.exceptions.InvalidHandlerStateazure.servicebus.exceptions.AutoLockRenewTimeoutazure.servicebus.exceptions.AutoLockRenewFailedazure.servicebus.exceptions.EventDataSendErrorazure.servicebus.exceptions.MessageSendFailedazure.servicebus.exceptions.MessageLockExpiredazure.servicebus.exceptions.MessageSettleFailedazure.servicebus.exceptions.MessageAlreadySettledazure.servicebus.exceptions.SessionLockExpiredBatchMessage creation is now initiated viacreate_batchon a Sender, usingadd()on the batch to add messages, in order to enforce service-side max batch sized limitations.Session is now set on the message itself, viasession_idparameter or property, as opposed to onSendorget_senderviasession.  This is to allow sending a batch of messages destined to varied sessions.Session management is now encapsulated within a property of a receiver, e.g.receiver.session, to better compartmentalize functionality specific to sessions.To useAutoLockRenewagainst sessions, one would simply pass the inner session object, instead of the receiver itself.0.50.2 (2019-12-09)New FeaturesAdded support for delivery tag lock tokensBugFixesFixed bug where Message would pass through invalid kwargs on init when attempting to thread through subject.Increments UAMQP dependency min version to 1.2.5, to include a set of fixes, including handling of large messages and mitigation of segfaults.0.50.1 (2019-06-24)BugFixesFixed bug where enqueued_time and scheduled_enqueue_time of message being parsed as local timestamp rather than UTC.0.50.0 (2019-01-17)Breaking changesIntroduces new AMQP-based API.Original HTTP-based API still available under new namespace: azure.servicebus.control_clientFor full API changes, please see updatedreference documentation.Within the new namespace, the original HTTP-based API from version 0.21.1 remains unchanged (i.e. no additional features or bugfixes)
so for those intending to only use HTTP operations - there is no additional benefit in updating at this time.New FeaturesNew API supports message send and receive via AMQP with improved performance and stability.New asynchronous APIs (usingasyncio) for send, receive and message handling.Support for message and session auto lock renewal via background thread or async operation.Now supports scheduled message cancellation.0.21.1 (2017-04-27)This wheel package is now built with the azure wheel extension0.21.0 (2017-01-13)New Featuresstrmessages are now accepted in Python 3 and will be encoded in 'utf-8' (will not raise TypeError anymore)broker_propertiescan now be defined as a dict, and not only a JSONstr. datetime, int, float and boolean are converted.#902 addsend_topic_message_batchoperation (takes an iterable of messages)#902 addsend_queue_message_batchoperation (takes an iterable of messages)Bugfixes#820 the code is now more robust to unexpected changes on the SB RestAPI0.20.3 (2016-08-11)News#547 Add get dead letter path static methods to Python#513 Add renew lockBugfixes#628 Fix custom properties with double quotes0.20.2 (2016-06-28)BugfixesNew header in Rest API which breaks the SDK #658 #6570.20.1 (2015-09-14)NewsCreate a requests.Session() if the user doesn't pass one in.0.20.0 (2015-08-31)Initial release of this package, from the split of theazurepackage.
See theazurepackage release note for 1.0.0 for details and previous
history on Service Bus.