azure function Python: How to send output to session enabled service bus queue

Mu Xu 21 Reputation points
2022-05-17T20:54:01.647+00:00

I couldn't find a proper way to set session id

def main(msg: func.ServiceBusMessage, resp: func.Out[str]):
logging.info('Python ServiceBus queue trigger processed message: %s',
msg.get_body().decode('utf-8'))
resp.set("received.")

{
"scriptFile": "init.py",
"bindings": [
{
"name": "msg",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "gridcalcrequest",
"connection": "rmbssbns_gcrequest",
"accessRights":"listen"
},{
"name": "resp",
"type": "serviceBus",
"direction": "out",
"queueName": "gridcalcresponse",
"connection": "rmbssbns_gcresponse"
}
]
}

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
544 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,263 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,421 Reputation points
    2022-05-23T09:01:43.187+00:00

    @Mu Xu ,

    Thanks for reaching out to Q&A.

    You can use the Azure service bus sdk for python to write messages to session enabled service bus queue. Please refer following example,
    https://learn.microsoft.com/en-us/python/api/overview/azure/servicebus-readme?view=azure-python#send-and-receive-a-message-from-a-session-enabled-queue

    I have converted the comment to answer so that it helps others in the community as well.

    1 person found this answer helpful.