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

Accepted answer
  1. Jaliya Udagedara 2,836 Reputation points MVP Volunteer Moderator
    2020-12-10T09:08:27.183+00:00

    Azure Functions can automatically perform builds on the code it receives after zip deployments.

    You can use this Azure Function App task

    More read,
    Deployment technologies in Azure Functions

    Specially,
    46819-image.png

    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Yvo Putter 6 Reputation points
    2021-02-09T09:24:32.937+00:00

    I gave up to try remote build after I found the github page for Azure Pipelines Tasks, and found many other similar issues.

    See in particular

    Seems remote build with the given task doesn't work specifically for Linux Consumption Plan (maybe Python in particular as well?).

    Resolved it by just building requirements.txt myself during build task, iso remote-build or installing azure cli tools and using func publish command (got permission denied errors).

    - bash: |
      if [ -f extensions.csproj ] 
      then
        dotnet build extensions.csproj --output ./bin
      fi
      pip install --target="__app__/.python_packages/lib/site-packages" -r __app__/requirements.txt
      displayName: "Build requirements.txt"
      - task: ArchiveFiles@2
    

  2. Tony Thorsen 1 Reputation point
    2021-10-07T18:48:39.97+00:00

    I know this is an old thread, but I've been fighting the same issues with Azure Pipelines, and what ultimately worked for me without having to add any '.js' files to the root or run custom inline scripts was to switch from using the 'AzureFunctionApp@1' task to the 'AzureWebApp@1' task with the options shown above (e.g. "deploymentMethod: zipDeploy").

    It seems this task does not add the 'WEBSITE_RUN_FROM_PACKAGE' setting automatically like the 'AzureFunctionApp@1' task does.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.