.net-coreazure-devopsazure-functionsazure-pipelinesazure-devops-self-hosted-agent

Azure devops deployment of azure function app creating extra folder in wwwroot


I had created azure function app with private endpoints. I created self host agent VM and pushed my ZIP file to same VNET that storage account, function app, VM resides. After deploying ,I see an extra folder inside wwwroot folder. Not sure what am doing wrong.

I am using classical pipeline approach.

Build Pipeline:

enter image description here

Release pipelines :

Option1: Tried with Azure CLI Task by deploying.

enter image description here

Option2: Tried with Azure FUnction App Deploy Task

enter image description here

Creating bin,function1,json files are inside "build" folder which should not be occurred.

Expected Output: All the files must be deploy under root folder.

enter image description here

Update: Based on comments suggested, I tried to reproduce the issue and fixed.

Before Issue fix: The azure function app code files resides inside build folder that downloaded build.zip artifact from build pipeline as show in below screenshot.

As my Azure CLI Task is deploying entire zip as it is, it is showing build folder under wwwrooot.

enter image description here

enter image description here

Changes done to CI pipeline:

Copy files from wwwroot/build folder to wwwroot using Pipeline Copy file task

enter image description here

Next In archive files Task i modified rootFolderOrFile to $(build.artifactstagingdirectory)/build

After CI pipeline runs, I again downloaded ZIP file to make sure ther is no build folder inside it. And it worked like a champ :)


Solution

  • I can't test my observation now, but I would first check the "rootFolderOrFile" line in the yaml code of the build pipeline.

    You can make settings something like this with a deploy task:

    - task: ExtractFiles
      displayName: 'Extract Website from Zip'
      inputs:
        archiveFilePatterns: '$(Pipeline.Workspace)/xy.zip'
        destinationFolder: '$(Pipeline.Workspace)'
        cleanDestinationFolder: true
        overwriteExistingFiles: false
    

    When you make a zip and unzip it, it creates a folder (which is also the name of the zip) and puts the unzipped files in it.

    ———

    EDIT: Okay, I see that you have includeRootFolder: false line but check the structure of your ZIP file to make sure it directly contains the files instead of an additional root folder.

    ———

    Workaround: In your current case, you will have to copy file from wwwroot/build folder to wwwroot using Pipeline Copy file task and after it you can delete the build folder with Delete files task.