Azure Service Bus client library for Python Samples

NOTE: This document outlines the samples for the latest version of the azure-servicebus package which has different APIs than the older version (0.50). Please visit this link for samples of version 0.50 of this library.

These are code samples that show common scenario operations with the Azure Service Bus client library. Both sync version and async version of samples are provided.

Prerequisites

  • Python 3.8 or later.
  • Microsoft Azure Subscription: To use Azure services, including Azure Service Bus, you'll need a subscription. If you do not have an existing Azure account, you may sign up for a free trial or use your MSDN subscriber benefits when you create an account.

Setup

  1. Install the Azure Service Bus client library for Python with pip:
pip install azure-servicebus

To run samples that utilize the Azure Active Directory for authentication, please install the azure-identity library:

pip install azure-identity
  1. Clone or download this sample repository.
  2. Open the sample folder in Visual Studio Code or your IDE of choice.

Running the samples

  1. Open a terminal window and cd to the directory that the samples are saved in.
  2. Set the environment variables specified in the sample file you wish to run.
  3. Follow the usage described in the file, e.g. python send_queue.py.

Next steps

Check out the API reference documentation to learn more about what you can do with the Azure Service Bus client library.