azure函数处于“只读模式”- AzureDevops管道从zip部署

cvxl0en2  于 2023-01-18  发布在  其他
关注(0)|答案(1)|浏览(142)

我正在使用Azure Devops管道部署Azure功能: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)

所有工作正常,部署无误。问题是该功能从未触发,并且每分钟都触发一次。Azure门户中有以下消息: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.
如何从Azure管道部署可以实际工作(被触发)的功能?
添加的功能代码:

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定位问题:手动和自动之间的绑定不同。
手册:

"bindings": [
            {
                "name": "myTimer",
                "type": "timerTrigger",
                "direction": "in",
                "schedule": "0 */1 * * * *"
            }

自动化:

"bindings": [
        {
            "name": "UpTimerDummy",
            "type": "timerTrigger",
            "direction": "in",
            "schedule": "0 */1 * * * *"
        },
        {
            "type": "queue",
            "name": "operationRequest",
            "queueName": "operations-queue",
            "connection": "AzureWebJobsStorage",
            "direction": "out"
        }

我猜我对AzureWebJobsStorage或操作队列都没有权限。

rekjcdws

rekjcdws1#

此部署任务有效。请检查部署结果:

检查您的函数内容...此外,您可以通过“测试/运行”按钮手动运行它:

使用async关键字测试函数,如下所示:https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-javascript#example

module.exports = async function (context, myTimer) {
    var timeStamp = new Date().toISOString();

    if (myTimer.isPastDue)
    {
        context.log('Node is running late!');
    }
    context.log('Node timer trigger function ran!', timeStamp);   
};

相关问题