Azure Storage Queue client library for Python Samples
These are code samples that show common scenario operations with the Azure Storage Queue client library.
The async versions of the samples (the python sample files appended with _async
) show asynchronous operations
with queues.
Contents
queue_samples_hello_world.py (async version) - Examples for getting started with queues:
- Client creation
- Create a queue
- Send messages
- Receive messages
queue_samples_authentication.py (async version) - Examples for authenticating and creating the client:
- From a connection string
- From a shared access key
- From a shared access signature token
- From Azure Active Directory
queue_samples_service.py (async version) - Examples for interacting with the queue service:
- Get and set service properties
- List queues in a storage account
- Create and delete a queue from the service
- Get the QueueClient
queue_samples_message.py (async version) - Examples for working with queues and messages:
- Set an access policy
- Get and set queue metadata
- Send and receive messages
- Delete specified messages and clear all messages
- Peek and update messages
network_activity_logging.py - Shows how to enable logging to console for the Storage Queues library:
- Setting up the logger and configuring output to STDOUT
- Setting the level on the logger
- Enabling the logger for the service and printing any logging messages
Prerequisites
- Python 3.6 or later is required to use this package
- You must have an Azure subscription and an Azure storage account to run these samples.
Setup
- Install the Azure Storage Queues client library for Python with pip:
pip install azure-storage-queue
- Clone or download this sample repository
- Open the sample folder in Visual Studio Code or your IDE of choice.
Running the samples
- Open a terminal window and
cd
to the directory that the samples are saved in. - Set the environment variables specified in the sample file you wish to run.
- Follow the usage described in the file, e.g.
python queue_samples_hello_world.py
Next steps
Check out the API reference documentation to learn more about what you can do with the Azure Storage Queues client library.