2025, Dec 20 23:00

Azure Functions Python Service Bus trigger not picking messages after deployment? The AzureWebJobsStorage fix

Deployed Azure Functions Python Service Bus trigger not firing? Fix InternalServerError by adding AzureWebJobsStorage and verifying ServiceBusConnectionString.

Azure Functions with Service Bus triggers often work flawlessly on a local machine, yet after deployment they refuse to pick messages. The runtime may even surface a generic InternalServerError in the Diagnose and solve problems area, which doesn’t immediately point to the real cause. Below is a concise walkthrough of the failure mode and the exact configuration change that restores the trigger in production.

Minimal example that reproduces the behavior

import logging
import json
import os
fx = func.FunctionApp()
logging.info("Function starting...")
print("Function starting...")
def parse_payload(msg: func.ServiceBusMessage):
    try:
        logging.info("Processing service bus message")
        raw = msg.get_body()
        text = raw.decode('utf-8')
        try:
            parsed = json.loads(text)
        except json.JSONDecodeError:
            parsed = text
        logging.info(f"Processed service bus message: {parsed}")
        return parsed
    except Exception as err:
        print(f"Error processing message: {str(err)}  ")
@fx.service_bus_queue_trigger(arg_name="sbmsg", queue_name="new-user", connection="ServiceBusConnectionString")
def handle_new_user(sbmsg: func.ServiceBusMessage):
    logging.info("Function called...")
    payload = parse_payload(msg=sbmsg)
    logging.info(f"Received message from queue: {payload}")
    logging.info("Function completed.")

What actually goes wrong after deployment

The trigger code is fine and proves itself locally, so attention naturally shifts to the cloud runtime. In the deployed Function App, the host runtime reports an InternalServerError and the Service Bus trigger never starts listening. The missing piece is an essential application setting that the Azure Functions host depends on at runtime for trigger orchestration.

The setting in question is AzureWebJobsStorage. It is required by Azure Functions to store logs, manage triggers for queues, blobs and Service Bus, and maintain state. If it’s not configured in App Settings, the runtime cannot initialize the trigger pipeline, which leads to the observed failure where no messages are picked up even though the same Service Bus connection string works locally.

The fix

Add the storage connection to the Function App configuration and restart the app. This change is made in the cloud app settings, not in code.

AzureWebJobsStorage : <StorageConnectionString>

After adding this setting under Function App > Environment variables > App Settings and restarting, the Service Bus queue trigger starts consuming messages as expected. This was verified by sending a message to the queue and observing successful invocations.

While you’re in configuration, double-check that the ServiceBusConnectionString app setting is present in Azure, matches the exact name used in your code, and carries at least Listen permissions. If the Function App shows as stopped in the Overview section, start it. To observe executions, use Functions > Invocations, and if Application Insights is enabled under Monitoring, check there as well. After sending a message to the queue, give it a moment and refresh Invocations to surface the logs.

Why this matters

AzureWebJobsStorage is not an optional convenience; it’s a core dependency of the Functions runtime. Without it, the host has nowhere to persist trigger metadata, logs, and state, which prevents trigger-based functions, including Service Bus, from initializing and running in Azure. Configuring this correctly ensures your production environment faithfully mirrors the behavior you see locally and gives you the operational telemetry required to troubleshoot.

Wrap-up

If your Python Service Bus trigger works locally but not after deployment, look past the function code and verify platform settings. Add AzureWebJobsStorage with a valid storage connection string in App Settings and restart the Function App. Make sure the ServiceBusConnectionString setting matches the name in your decorator and has proper Listen permissions. Confirm the app is running in Overview, then watch Invocations and Application Insights for successful runs. With these pieces in place, the trigger reliably picks up messages in Azure, just as it does on your machine.