[Python] Azure Functions Service Bus Triggered not working

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    This is my Python code for Azure functions.

    import logging
    import json

    app = func.FunctionApp()
    logging.info("Function starting...")
    print("Function starting...")

    import os

    def process_message(message: func.ServiceBusMessage):
    try:
    logging.info("Processing service bus message")
    # Join all chunks and decode to string
    body_bytes = message.get_body()
    body_str = body_bytes.decode('utf-8')
    try:
    result = json.loads(body_str)
    except json.JSONDecodeError:
    result = body_str
    logging.info(f"Processed service bus message: {result}")
    return result

    except Exception as e:
    print(f"Error processing message: {str(e)} ")

    @app.service_bus_queue_trigger(arg_name="azservicebus", queue_name="new-user", connection="ServiceBusConnectionString")
    def new_user_job_recommendation(azservicebus: func.ServiceBusMessage):
    logging.info("Function called...")
    user_id = process_message(message=azservicebus)
    logging.info(f"Received message from queue: {user_id}")

    logging.info("Function completed.")


    This code works locally and is able to fetch messages from service bus.

    But after deploying it does not pick messages from service bus (i am using same connection string).

    This is my app settings. App Settings

    Also here you can see it has linked with App Settings variable Trigger Details

    Continue reading...

Compartilhe esta Página