How do I create/connect to a Docker Azure service bus (using Python SDK)?

Viewed 856

I'm using the Python 3.8 SDK for Azure service bus, (azure-servicebus v. 0.50.3). I use the following code to send a message to a topic ...

service = ServiceBusService(service_namespace,
                        shared_access_key_name=key_name,
                        shared_access_key_value=key_value)
msg = Message(json.dumps({'type': 'my_message'}))
service.send_topic_message(topic_name, msg)

How do I create a Docker image that runs the service bus with a topic or two already created? I found this image

version: '3.7'

services:
    azure_sb:
        container_name: azure_sb
        image: microsoft/azure-storage-emulator
        tty: true
        restart: always
        ports:
            - "10000:10000"
            - "10001:10001"
            - "10002:10002"

but I'm unclear how to connect to it using the code I have or if the above is even a valid service bus image.

1 Answers

Azure Service Bus does not provide a docker image. The image that you are using (microsoft/azure-storage-emulator) is for the Azure Storage system, which can provide similar queuing capabilities with Azure Storage Queues. For more details check out How to use Azure Queue storage from Python.

If you need to use Azure Service Bus locally, check out the GitHub Issue: Local Development story?. TLDR: Use AMQP libraries and connect to another AMQP provider for local, and swap out for Service Bus in production.

Related