'Azure Queue Trigger Function not firing
I have designed a Azure Queue Trigger function in Python with the following functionalities.
- When a message is added to Queue named Input , the function fires
- It processes the message added to the Input Queue and stores the result in Output Queue
Now my problem is this is working fine when I run locally . But after deploying the function app and then if I add a message to the Input Queue , the function is not firing .
Checked everything . Here is my function.json for reference .
I havent been able to locate anything relevant to this in documentation and not sure what I'm missing .
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "msg",
"type": "queueTrigger",
"direction": "in",
"queueName": "input-messages-queue",
"connection": "AzureWebJobsStorage"
},
{
"type": "queue",
"direction": "out",
"name": "outputmessage",
"queueName": "output-responses-queue",
"connection": "AzureWebJobsStorage"
}
]
}
Solution 1:[1]
In my case I forgot to add the settings from my "local.settings.json" file in "Configuration" of the Azure Function App in the portal. Not doing this will not add the connection string for the queue and your function will never be triggered.
Solution 2:[2]
figured out my mistake . I created the queues in a different storage-account . But the function was pointing out to the storage-account where it was created within a different resource group. I created those queues in the same storage-account and voila it worked
Solution 3:[3]
Make sure the configuration entity is set up in the portal. I was using a custom config key for the connection name, but did not set the value for it, only locally, so the queue did not trigger the function running in the cloud.
Solution 4:[4]
In Visual Studio 2022, bindings to Azure Queue are stored in local.settings.json config files for local execution, for example:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": <Azure Storage Key 1 - taken from Azure Portal>,
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"azurestoragetest": <Azure Storage Key 1 - taken from Azure Portal> }
}
<Azure Storage Key 1> is Access Key for Azure Storage stored in Azure Portal.
However, when Azure Function is Published to Azure, the values for the bindings are not published (deployed) until set specifically in dependencies.
In VS select project, right click and choose Publish. On Publish page go to Service Dependencies, locate Azure Storage, click "..." to open Edit dependencies menu. From there on 2nd page there is option "Save connection string value in" - set it to Azure App Settings. By default, this setting is set to "None" - meaning Publish will not store bindings values in Azure.
The json config file in Azure for Azure Function stores only bindings, but not values of these bindings (for security reasons), so it doesn't tell us whether bindings are assigned any values or not.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nishat Sayyed |
Solution 2 | Rajesh Rajamani |
Solution 3 | klenium |
Solution 4 | Daniel D |