This project demonstrates how to use Azure Service Bus to publish and subscribe the messages using two different method:
connection_string_basedpasswordless authentication.
Azure Service Bus offers three pricing tiers. For this project, the Premium tier was selected due to its support for a maximum message size of 100MB.
- Different message size was published & subscribed
[1MB, 10MB, 95MB, 100MB]
- Python
3.8or higher pip(Python package installer)- An
Azure accountwith an active subscription
Clone the repository:
git clone https://github.com/Mazhar004/azure-service-bus-pub-sub.gitCreate a .env file in the root of your project & insert your secrets. Here's an example:
FULLY_QUALIFIED_NAMESPACE=YOUR_SERVICE_BUS_NAME.servicebus.windows.net
# Required Connection String Based Configuration
CONNECTION_STR=
# Required for Password Less Configuration
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=
AZURE_TENANT_ID=
# Required for Publisher & Subscriber
TOPIC_NAME=
# Required for Subscriber Only
SUBSCRIPTION_NAME=-
Create a
virtualenvironment:python3 -m venv venv
-
Activate the
virtualenvironment:-
On
UnixorMacOS:source venv/bin/activate
-
-
Upgrade
pip:pip install --upgrade pip setuptools
-
Installthe required packages:pip install -r requirements.txt
-
Install
Azure CLI:For
Linux:- Follow the guidline Link
For
macOS:brew update && brew install azure-cli -
Login to
Azure:az login
To publish a message, run the following command:
python publisher.py --msg "Your message here" --pubsubTo start the subscriber, run the following command:
python subscriber.py- Create a
.envfile in the root of your project & insert your secrets Sample Configuration
docker build -t pubsubapp .- Subcriber
docker run pubsubapp python subscriber.py
- Publisher
docker run pubsubapp python publisher.py --msg "your msg" --pubsub
This project is licensed under the terms of the LICENSE file.

