I am running a service using Flask that, when a message is published on a topic, needs to trigger some code. I am unsure how to create the subscription name and all that, but I think I can hack at it. What I really don't know is how to be constantly listening to this topic and initiate the filters such that whenever a message that matches the criteria is met, it is always triggered. Is there some place I can be directed to?
Asked
Active
Viewed 724 times
1 Answers
1
You'd better use Azure Functions which will be triggered whenever a new message arrives in the topic:
import azure.functions as func
import logging
import json
def main(msg: func.ServiceBusMessage):
logging.info('Python ServiceBus queue trigger processed message.')
result = json.dumps({
'message_id': msg.message_id,
'body': msg.get_body().decode('utf-8'),
'content_type': msg.content_type,
'expiration_time': msg.expiration_time,
'label': msg.label,
'partition_key': msg.partition_key,
'reply_to': msg.reply_to,
'reply_to_session_id': msg.reply_to_session_id,
'scheduled_enqueue_time': msg.scheduled_enqueue_time,
'session_id': msg.session_id,
'time_to_live': msg.time_to_live,
'to': msg.to,
'user_properties': msg.user_properties,
'metadata' : msg.metadata
})
logging.info(result)

Thiago Custodio
- 17,332
- 6
- 45
- 90
-
Quick question about this solution: I've been looking and it seems like it requires the installation of a .NET framework. Is my assumption correct? Because if it is, I cannot do that. – John Lexus Jan 16 '21 at 15:30
-
no, you can use python sdk https://github.com/Azure/azure-functions-python-library – Thiago Custodio Jan 16 '21 at 16:52