I need to create some entities in Azure ServiceBus using Python.
Creating a Queue works like a charm:
adminClient.create_queue('<name>', default_message_time_to_live='P8D', uplicate_detection_history_time_window='PT1H', lock_duration='PT1M', max_delivery_count=100, max_size_in_megabytes=4096, max_message_size_in_kilobytes=256)
The Queue gets created without a Shared access policy, so I want to achieve that in code as well:
adminClient.create_queue('<name>', authorization_rules=[ AuthorizationRule(type='SharedAccessPolicy',key_name='...',rights=[ 'Send' ]) ], default_message_time_to_live='P8D', uplicate_detection_history_time_window='PT1H', lock_duration='PT1M', max_delivery_count=100, max_size_in_megabytes=4096, max_message_size_in_kilobytes=256)
Running this code throws azure.core.exceptions.HttpResponseError: SubCode=50000. Internal Server Error. I don't even know if SharedAccessPolicy is correct as type. I tried adding primary_Key='...' and secondary_key='...', but got the same result.
I am aware of the documentation found at https://azuresdkdocs.blob.core.windows.net/$web/python/azure-servicebus/latest/azure.servicebus.management.html#azure.servicebus.management.AuthorizationRule, but it doesn't really help.
What am I missing?
This worked for me.
I have used
azure.mgmt.servicebusfromazure-mgmt-servicebuspackage.For reference check this document.
My Code:
app.py:OUTPUT: