I have created a service bus queue with send and listen permission.
Using C# programming language I am able to the read the data from that queue.
But when I am trying the same thing with python I am facing some problems, also I am new with Python and using Azure services with it. Below are the code snippets which are giving me the error.
Snippet 1
from azure.servicebus import QueueClient, Message
# Create the QueueClient
queue_client = QueueClient.from_connection_string(
"<CONNECTION STRING>", "<QUEUE NAME>")
# Receive the message from the queue
with queue_client.get_receiver() as queue_receiver:
messages = queue_receiver.fetch_next(timeout=3)
for message in messages:
print(message)
message.complete()
Error
Traceback (most recent call last):
File "C:\installs\readBus1.py", line 1, in <module>
from azure.servicebus import QueueClient, Message
ImportError: cannot import name 'QueueClient'
Snippet 2
from azure.servicebus.control_client import ServiceBusService, Message, Topic, Rule, DEFAULT_RULE_NAME
bus_service = ServiceBusService(
service_namespace='<NameSpace>',
shared_access_key_name='<KeyName>',
shared_access_key_value='<ConnectionString>')
msg = bus_service.receive_subscription_message('fileupload', 'AllMessages', peek_lock=True)
if msg.body is not None:
print(msg.body)
msg.delete()
Error
Traceback (most recent call last):
File "C:\installs\readBus1.py", line 2, in <module>
from azure.servicebus.control_client import ServiceBusService, Message, Topic, Rule, DEFAULT_RULE_NAME
ModuleNotFoundError: No module named 'azure.servicebus.control_client'
I am using Python 3.6, also I installed Azure services using command
pip install azure
I am new to Python and using it with Azure.