azure-functions-python-worker
azure-functions-python-worker copied to clipboard
Unable to send messages to service bus topic
Is your question related to a specific version? If so, please specify:
azure-functions 1.7.2
What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)
Service bus
Question
I am unable to successfully send a message to Azure Service Bus Topic. I've configured the serverless function with the following function.json file:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "inputmsg",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "queuename",
"connection": "AzureServiceBusConnectionString"
},
{
"name": "msg",
"type": "serviceBus",
"direction": "out",
"topicName": "outputtopicname",
"connection": "AzureServiceBusConnectionString"
}
],
"retry": {
"strategy": "exponentialBackoff",
"maxRetryCount": 5,
"minimumInterval": "00:00:01",
"maximumInterval": "00:00:30"
}
}
and the following function:
import json
import azure.functions as func
def main(inputmsg: func.ServiceBusMessage, msg: func.Out[str]):
data = json.loads(inputmsg.get_body().decode("utf-8"))
result = process_data(data)
msg.set(json.dumps(result))
I am unsure why the messages are not being sent to the service bus topic. With this code and configuration, I am able to read the message from the service bus queue, but sending them out to the topic does not work.
This is a similar configuration and code to another serverless function I've wrote which sends messages to a service bus queue, but that function works correctly.
I am also wondering how I could set custom properties on the message which is sent to the topic, so that I can make use of the correlation filters for topic subscriptions.
Thanks
@stefanushinardi