Skip to content
Skillpedia
APIs & servers (backend)48k · #2373

azure-servicebus-py

Makes your agent reliably exchange messages using queues and topics. Useful for connecting different program parts.

What it does

This tool allows computer programs to send and receive messages reliably. It's like a postal service for applications, ensuring messages reach their intended destination even across distributed systems.

When to use it

  • ✓When one application needs to send data to another without waiting for an immediate response.
  • ✓To ensure important messages aren't lost between different parts of a system.
  • ✓When building systems that need to handle many tasks or events in an organized way.

Example of what to ask your AI

“Send a 'Hello World' message to the queue 'my-queue'.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-servicebus-py/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-servicebus-py/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The program connects to a cloud messaging service (Azure Service Bus) and uses 'senders' to dispatch messages and 'receivers' to pick them up. It manages the sending and receiving securely and reliably.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add sickn33/agentic-awesome-skills --skill azure-servicebus-py

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/azure-servicebus-py/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Bundled upstream support

Supporting files are included at skill-relative paths. See UPSTREAM-NOTICE.md for their pinned sources, licenses, hashes, and import changes.

Restored helper safety

scripts/setup_servicebus.py can create or delete Service Bus queues, topics, and subscriptions. Delete commands require --confirm-delete; subscription creation with --filter replaces the default rule on the newly created subscription. Confirm the namespace and exact entity/action with the user before live use; prefer a disposable test namespace.

Azure Service Bus SDK for Python

Enterprise messaging for reliable cloud communication with queues and pub/sub topics.

Installation

pip install azure-servicebus azure-identity

Environment Variables

SERVICEBUS_FULLY_QUALIFIED_NAMESPACE=<namespace>.servicebus.windows.net
SERVICEBUS_QUEUE_NAME=myqueue
SERVICEBUS_TOPIC_NAME=mytopic
SERVICEBUS_SUBSCRIPTION_NAME=mysubscription

Authentication

from azure.identity import DefaultAzureCredential
from azure.servicebus import ServiceBusClient

credential = DefaultAzureCredential()
namespace = "<namespace>.servicebus.windows.net"

client = ServiceBusClient(
    fully_qualified_namespace=namespace,
    credential=credential
)

Client Types

Client Purpose Get From
ServiceBusClient Connection management Direct instantiation
ServiceBusSender Send messages client.get_queue_sender() / get_topic_sender()
ServiceBusReceiver Receive messages client.get_queue_receiver() / get_subscription_receiver()

Send Messages (Async)

import asyncio
from azure.servicebus.aio import ServiceBusClient
from azure.servicebus import ServiceBusMessage
from azure.identity.aio import DefaultAzureCredential

async def send_messages():
    credential = DefaultAzureCredential()
    
    async with ServiceBusClient(
        fully_qualified_namespace="<namespace>.servicebus.windows.net",
        credential=credential
    ) as client:
        sender = client.get_queue_sender(queue_name="myqueue")
        
        async with sender:
            # Single message
            message = ServiceBusMessage("Hello, Service Bus!")
            await sender.send_messages(message)
            
            # Batch of messages
            messages = [ServiceBusMessage(f"Message {i}") for i in range(10)]
            await sender.send_messages(messages)
            
            # Message batch (for size control)
            batch = await sender.create_message_batch()
            for i in range(100):
                try:
                    batch.add_message(ServiceBusMessage(f"Batch message {i}"))
                except ValueError:  # Batch full
                    await sender.send_messages(batch)
                    batch = await sender.create_message_batch()
                    batch.add_message(ServiceBusMessage(f"Batch message {i}"))
            await sender.send_messages(batch)

asyncio.run(send_messages())

Receive Messages (Async)

async def receive_messages():
    credential = DefaultAzureCredential()
    
    async with ServiceBusClient(
        fully_qualified_namespace="<namespace>.servicebus.windows.net",
        credential=credential
    ) as client:
        receiver = client.get_queue_receiver(queue_name="myqueue")
        
        async with receiver:
            # Receive batch
            messages = await receiver.receive_messages(
                max_message_count=10,
                max_wait_time=5  # seconds
            )
            
            for msg in messages:
                print(f"Received: {str(msg)}")
                await receiver.complete_message(msg)  # Remove from queue

asyncio.run(receive_messages())

Receive Modes

Mode Behavior Use Case
PEEK_LOCK (default) Message locked, must complete/abandon Reliable processing
RECEIVE_AND_DELETE Removed immediately on receive At-most-once delivery
from azure.servicebus import ServiceBusReceiveMode

receiver = client.get_queue_receiver(
    queue_name="myqueue",
    receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE
)

Message Settlement

async with receiver:
    messages = await receiver.receive_messages(max_message_count=1)
    
    for msg in messages:
        try:
            # Process message...

…
FAQ

What are queues and topics?

Queues are like mailboxes where a message goes to a single recipient. Topics are like bulletin boards where a message can be seen by multiple interested subscribers.

How are messages processed?

Messages can be received and deleted immediately, or they can be received and locked for processing. If processing fails, the message can be retried or moved to a 'dead-letter queue' for review.

Is it secure to use?

Yes, it uses secure credentials to connect to the service and ensures messages are delivered reliably, even if temporary failures occur.

Details

Original description by the author

Azure Service Bus SDK for Python messaging. Use for queues, topics, subscriptions, and enterprise messaging patterns.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#2373
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills