Azure DevOps Function App Deployment „No package found“

Problem

##[error]Error: No package found with specified pattern: /home/vsts/work/1/a/**/*.zip
Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

This error occurs using the default MS deployment example. Even if we have an uploaded artefact

Solution

The problem is, that we have a deployment step by default but the MS documentation is outdated and so is missing the download step:

- task: DownloadBuildArtifacts@1
  inputs:
    buildType: 'current'
    downloadType: 'single'
    artifactName: 'drop'
    itemPattern: '**/*.zip'
    downloadPath: '$(System.ArtifactsDirectory)'

As so we have to:

  1. build
  2. publish -> ArchiveFiles & PublishBuildArtifacts
  3. download an artefact -> DownloadBuildArtifacts
  4. deploy: before we can trigger the deploy AzureFunctionApp task.

Deploy Node Function App using Azure DevOps

The full build and deploy Azure DevOps scripts looks than like:

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
variables:
  # Azure service connection established during pipeline creation
  azureSubscription: '<azure-subscription-name>'
  appName: '<azure-function-app-name>'

trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '16.x'
  displayName: 'Install Node.js'
- script: |
    if [ -f extensions.csproj ]
    then
        dotnet build extensions.csproj --output ./bin
    fi
    npm install 
    npm run build --if-present
    npm prune --production  
- task: ArchiveFiles@2
  displayName: "Archive files"
  inputs:
    rootFolderOrFile: "$(System.DefaultWorkingDirectory)"
    includeRootFolder: false
    archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
    artifactName: 'drop'
- task: DownloadBuildArtifacts@1
  inputs:
    buildType: 'current'
    downloadType: 'single'
    artifactName: 'drop'
    itemPattern: '**/*.zip'
    downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureFunctionApp@1
  inputs:
    azureSubscription: $(azureSubscription)
    appType: functionAppLinux # default is functionApp
    appName: $(appName)
    package: '$(System.DefaultWorkingDirectory)/**/*.zip'
    runtimeStack: 'NODE|16' # this is optional
    deploymentMethod: 'auto' # auto is default
    #Uncomment the next lines to deploy to a deployment slot
    #Note that deployment slots is not supported for Linux Dynamic SKU
    #deployToSlotOrASE: true
    #resourceGroupName: '<Resource Group Name>'
    #slotName: '<Slot name>'

Links

Paul Sterl has written 55 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>