I am deploying azure function using Azure Devops pipeline:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-function-app-v1?view=azure-pipelines
- task: AzureFunctionApp@1
displayName: 'Deploy functions to Function App'
inputs:
azureSubscription: Subscription
appType: functionAppLinux
appName: 'functionX'
package: $(System.DefaultWorkingDirectory)/functions.zip
resourceGroupName: $(resourcegroup)
All works great and gets deployed no errors. The problem is the function is never triggered, and the trigger is cron every minute.
There is this message in the azure portal:
Your app is currently in read only mode because you are running from a package file. To make any changes update the content in your zip file and WEBSITE_RUN_FROM_PACKAGE app setting
.
How can I deploy function from Azure Pipelines that can actually work (be triggered)?
Added function code:
module.exports = function (context, scaleUpTimer) {
var timeStamp = new Date().toISOString();
if(scaleUpTimer.isPastDue)
{
context.log('JavaScript is running late!');
}
context.log('JavaScript timer trigger function ran!', timeStamp);
context.done();
};
P.S
localized the issue: Had different bindings between manual and automated one.
manual:
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */1 * * * *"
}
automated:
"bindings": [
{
"name": "UpTimerDummy",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */1 * * * *"
},
{
"type": "queue",
"name": "operationRequest",
"queueName": "operations-queue",
"connection": "AzureWebJobsStorage",
"direction": "out"
}
My guess is I have no rights to either AzureWebJobsStorage or operations queue.
2
Answers
it turns out the binding:
was causing this. basically I have some rights issue with this request which causes the function not to invoke. still investigating this, but it is the reason.
This deployment task works. Check your deployment result:
Check your function contents… Additionally, you may run it manually through the Test/Run button:
Test you function with
async
keyword like here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-javascript#example