Azure Function Published with Azure DevOps has Extra Folder at Root

I was deploying an Azure Function with Azure DevOps and was running into a problem where an extra folder was created at the root of the Files directory when deploying. It looked like this:

I discovered that in the deployment file the root directory was being included in the deployed zip file and needed to be excluded in order for the correct file structure to be created. You can see that I’ve indicated “includeRootFolder” as “false” below.

- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true

The full code to publish to an Azure Function through the build pipeline is here, so give it a shot if you are running into more problems.

Enjoy!

Nathan Lasnoski

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s