I am using Python v2 programming model to develop azure function for topic output. I want to implement filters so i want to send key value in custom properties in topic but I am unable to set custom properties to message. My code is below.

One 08 0 Reputation points

@app.service_bus_topic_output(arg_name="message", connection="ServiceBusConnectionString", topic_name="testtopicdl")
def test_function(req: func.HttpRequest, message: func.Out[ServiceBusMessage]) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    sub = req.route_params.get('sub')
    # logging.info(type(ServiceBusMessage))
    if sub is not None:
        # message_body = {
        #     "msg" : "Hello " + sub,
        #     "sub" : "sub1"
        # }
        message_body = "Hello " + sub
        message_body = send_message(message_body)
        # logging.info(message_body)
        # custom_properties = {
        #     "sub":"sub1"
        # Add more custom properties as needed
    # }
        # message_body_str = json.dumps(message_body)
        logging.info('sub is none')
    return 'ok'

def send_message(toSub: str):
    message_body = "Hello, " + toSub
    # Create a ServiceBusMessage instance
    message = ServiceBusMessage(json.dumps({
        "msg":"Hello all"
    # message.application_properties = {

    # }
    return message
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,617 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,266 Reputation points

    One 08 Thanks for posting your question in Microsoft Q&A. Currently, outbound message doesn't support additional attributes such as application properties (or user/custom properties) and feature request #1139 is still open. Please refer to the doc https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-output?pivots=programming-language-python&tabs=python-v2%2Cin-process%2Cextensionv5#example for more info on supported parameters.

    If you have any feedback on this, please feel free to submit it in GitHub repo or via Azure Functions. Others with similar interests can upvote your idea too. I hope this helps and let me know if you have any questions.

    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    0 comments No comments