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

Hector Romo 151 Reputation points
2020-12-09T15:36:03.903+00:00

I'm using puppeteer in a node.js function app on a linux machine successfully.
Currently I'm deploying it directly from VS Codee
![46659-cleanshot-2020-12-09-at-162855.png][1]
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: https://dev.to/azure/running-headless-chromium-in-azure-functions-with-puppeteer-and-playwright-2fgk

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,678 questions
0 comments No comments
{count} votes

6 additional answers

Sort by: Most helpful
  1. Javaad Patel 11 Reputation points
    2020-12-25T11:31:54.84+00:00

    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
    2020-12-11T11:15:34.667+00:00

    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
    2021-02-08T11:31:15.387+00:00

    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
    2020-12-10T22:35:42.673+00:00

    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:

       stages:  
         - stage: Build  
           displayName: Build stage  
           jobs:  
             - job: Build  
               displayName: Build  
               pool:  
                 vmImage: $(vmImageName)  
         
               steps:  
                 - task: ArchiveFiles@2  
                   displayName: "Archive files"  
                   inputs:  
                     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"  
                   inputs:  
                     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?

    /Hector