python-3.xdjangoazureazure-web-app-serviceazure-webjobs

Azure WebJobs won't get triggered from Azure Storage Queue


Context

Problem

The celery runs absolutely fine.

However, when I set up a trigger from the storage queue, it doesn't work. I try by manually sending a message in the Queue.

Here are some code for reference

{
    "bindings": [
        {
            "name": "myQueueItem",
            "type": "queueTrigger",
            "direction": "in",
            "queueName": "%AZURE_STORAGE_QUEUE_NAME%",
            "connection": "AzureWebJobsStorage"
        }
    ],
    "disabled": false
}
{
    "stopping_wait_time": 60,
    "is_singleton": true
}
#!/bin/bash
# Activate the Python environment
echo "Triggerd"

Attempts

  1. I was initially trying Managed Identity so I set up following environment variables (or app settings)
AzureWebJobsStorage__credential: 'managedidentity'
AzureWebJobsStorage__accountName: storageAccount.name
AzureWebJobsStorage__queueServiceUri: 'https://${storageAccount.name}.queue.${storageSuffix}/'
  1. I have also attempted to setup via Connection String. I copied from Azure Storage Account UI/UX. I was able to connect from my local system.

I have tried combination of 1 and 2 along with different configuration in function.json, nothing works.

Edit:


Solution

  • You would need to create Python Function App, please see the example below:
    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-trigger?tabs=python-v2%2Cisolated-process%2Cnodejs-v4%2Cextensionv5&pivots=programming-language-python

    For Python triggers and bindings are not supported to run as web job, instead you would need to create function app.