Deploy azure function with pipeline and build on server. SCM_DO_BUILD_DURING_DEPLOYMENT=true

Hector Romo 151 Reputation points

I'm using puppeteer in a node.js function app on a linux machine successfully.
Currently I'm deploying it directly from VS Codee
And this is the .vscode/settings.json

    "azureFunctions.deploySubpath": ".",
    "azureFunctions.projectLanguage": "JavaScript",
    "azureFunctions.projectRuntime": "~3",
    "debug.internalConsoleOptions": "neverOpen",
    "azureFunctions.scmDoBuildDuringDeployment": true

But I would like to deploy it with azure pipelines.
The thing is that for puppeteer to work you need to build during deployment.
Here is the tutorial that helped me figure this out:

But I cant create a pipeline in that deploys builds it on server. I'm trying to use the setting SCM_DO_BUILD_DURING_DEPLOYMENT=true in app settings.
Any idea what steps to include or if there is any pipeline-template for that?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,395 questions
0 comments No comments
{count} votes

6 additional answers

Sort by: Most helpful
  1. Javaad Patel 11 Reputation points

    This is a great thread, I'm having the exact same issue. I tried setting WEBSITE_RUN_FROM_PACKAGE=0 but whenever I deploy from Azure DevOps it keeps resetting it to the package url. My devops yml looks the same as yours, I also created an empty server.js file but then my function stopped responding at all giving a 404 when it would usually find the function. How do you stop the pipeline from updating the WEBSITE_RUN_FROM_PACKAGE setting?

    2 people found this answer helpful.
    0 comments No comments

  2. Hector Romo 151 Reputation points

    Ok, I tried to create a new function app and a new pipeline and got it working.

    The difference is that I added an empty server.js file in the root.
    According to this readme
    a server.js or app.js file must be present for oryx to understand that it is a node.js project.

    Also I deployed the function app in US West central, not in North Europe like the first function app.

    Thanks a lot for your guidance :)

    1 person found this answer helpful.
    0 comments No comments

  3. Yvo Putter 6 Reputation points

    We're having the exact same issue, the deploy task AzureFunctionApp@1 always keeps adding adding WEBSITE_RUN_FROM_PACKAGE = package_url.

    Even if we:

    • use a new azure functions resource (region West Europe)
    • in pipelines task, set appSetting: "-ENABLE_ORYX_BUILD true -SCM_DO_BUILD_DURING_DEPLOYMENT true"
    • in pipelines task, add to appSetting: "-WEBSITE_RUN_FROM_PACKAGE 0" (it just overwrites it to package_url during pipeline run)
    • in pipelines task, set deploymentMethod = zipdeploy (doesn't seem to do anything compared to auto or run_from_package)

    In our case we have Python (3.8) durable functions (V3) on a Linux Consumption Plan

    1 person found this answer helpful.

  4. Hector Romo 151 Reputation points

    Hi @Jaliya Udagedara

    Thanks for your answer!
    So, I manage to push it as a zip file to the server. But it seems it does not build.

    This is part of my pipeline:

         - stage: Build  
           displayName: Build stage  
             - job: Build  
               displayName: Build  
                 vmImage: $(vmImageName)  
                 - task: ArchiveFiles@2  
                   displayName: "Archive files"  
                     rootFolderOrFile: "$(System.DefaultWorkingDirectory)"  
                     includeRootFolder: false  
                     archiveType: zip  
                     archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip  
                     replaceExistingArchive: true  
                 - task: AzureFunctionApp@1  
                   condition: succeeded()  
                   displayName: "Azure Functions App Deploy"  
                     azureSubscription: "$(azureSubscription)"  
                     appType: functionAppLinux  
                     appName: $(functionAppName)  
                     deploymentMethod: zipDeploy  
                     package: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip  

    When I deploy with this pipeline it adds the app config WEBSITE_RUN_FROM_PACKAGE: <url> to my function app. I believe that's why it doesnt build on server, but i can't figure out how to change that (I have deploymentMethod: zipDeploy in the pipeline). Do you see any error in my pipeline? Or is there any setting that is missing?