We would like to send messages to different Service Bus topics using the Python SDK from an Azure Function. We prefer not to use bindings as we will be deciding which topics to send data to dynamically and we would like to avoid using the service bus key for authentication.
In the following page:
Quickstart: Use Service Bus topics and subscriptions with Python
The following code is used to create an instance of the ServiceBusService class:
bus_service = ServiceBusService( service_namespace='<namespace>', shared_access_key_name='<sharedaccesskeyname>', shared_access_key_value='<sharedaccesskeyvalue>')
We would like to avoid having to plug in the Key value in there and instead use MSIAuthentication class from the msrestazure.azure_active_directory package.
We tried using the authentication parameter in the ServiceBusService class with something like:
bus_service = ServiceBusService( service_namespace='ournamespace' authentication=MSIAuthentication())
Our Azure Function has a System Assigned Identity against it and we have tested that we can successfully perform various operations with this mode of authentication from our function.
However, when using the MSIAuthentication() with the ServiceBusService class, the SDK always errors with:
AttributeError: 'MSIAuthentication' object has no attribute 'sign_request'.
We have the same issue trying locally with the ServicePrincipalCredentials class.
How can we send messages to Service Bus topic with alternative ways of authenticating rather than using the Service Bus key?