Search code examples
pythonazure-databricksazureservicebus

Problem with receiving message from Azure service bus in Azure databricks


I've got a problem with receiving a message from azure service bus queue in azure databricks, can't establish a connection with service bus queue from azure databricks notebook using python.

When using normal code without specifying the TransportType I'm getting given error, so suspecting either ports are closed.

enter image description here

So I tried specifying TransportType to transport_type=TransportType.AmqpOverWebsocket in the from_connection_string to change the port, but then I'm getting a strange error that 'str' object has no attribute 'AmqpOverWebsocket', please see the error below.

enter image description here

Any help would be amazing, thanks in advance!

I tried changing the transportType attribute to AmqpOverWebsocket, but next error occured. I verified that the queue is up and running, functions normally in azure portal.


Solution

  • In your connection string itself add ";TransportType=AmqpWebSockets".

    Original Connection String - Endpoint=sb://<>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<>

    Modified Connection String - Endpoint=sb://<>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<>;TransportType=AmqpWebSockets