Reputation: 55
I'd like to directly read messages from Azure Service Bus with Nuclio using the Python runtime. Does anyone have experience with this?
I'm assuming I need to create the ServiceBusClient inside of an init_context function, but the examples from azure show that occurring within it's own context manager, like so:
conn_str = <CRED>
queue_name = <NAME>
with ServiceBusClient.from_connection_string(conn_str) as client:
with client.get_queue_receiver(queue_name, max_wait_time=30) as receiver:
for msg in receiver:
print(str(msg))
I'm assuming best practice would be to create the ServiceBusClient inside of init_context, then call setattr(context.user_data, 'my_servicebus', my_servicebus.from_connection_string())
Anyone have experience with this?
Upvotes: 1
Views: 61
Reputation: 138
I suggest you explore connecting the Service Buss to Azure Event Hub. Although your idea of initiating the connection in init_context is a good start, you will have the complexity of managing the state and configuration of the ESB connection.
Nuclio includes an Azure Event Hub trigger. Not only will it simplify your deployment, but you will take advantage of Nuclio’s autoscaling and recovery options.
I found this article that seems to guide you through integrating ESB with Hub.
Upvotes: 0