I have multiple .net mvc apps and 1 .net azure function app in our solution. I have a azure-pipeline.yml file for deployment. Mvc apps goes to app services and Function app goes to azure function.
Now when I run the pipeline on azure devops, it deploys webapps to respective app service but it fails to deploy the azure function with the error:
##[error]Error: No package found with specified pattern: D:\a\1\a**\FunctionApp.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. Finishing: AzureFunctionApp
But I can see FunctionApp.zip in build artifacts.
Here is my yml:
trigger:
- master
- feature/*
- hotfix/*
pool:
vmImage: 'windows-2019'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isDeployableBranch: $[eq(variables.isMaster, true)]
stages:
- stage: Build
displayName: Build and Test Package
jobs:
- job: Build_Test_Publish
displayName: Build_Test_Publish
steps:
- task: NuGetToolInstaller@1
- task: VisualStudioTestPlatformInstaller@1
displayName: 'Install Visual Studio Test Platform'
inputs:
packageFeedSelector: 'nugetOrg'
versionSelector: 'latestStable'
- task: NuGetCommand@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'config'
nugetConfigPath: './'
externalFeedCredentials: 'Telerik NuGet'
- task: VSBuild@1
displayName: 'Build Solution'
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=$(isDeployableBranch) /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
displayName: 'Run Unit Tests'
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
condition: and(succeeded(), eq(variables.isDeployableBranch, true))
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: Deploy
displayName: Deploy
condition: and(succeeded(), eq(variables.isDeployableBranch, true))
jobs:
- deployment: DeployWebApp1
displayName: Deploy Web App 1
environment: 'PROD'
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'MyResourcegroup'
appType: 'webApp'
WebAppName: 'webapp1'
packageForLinux: '$(System.ArtifactsDirectory)/**/WebApp1.zip'
- deployment: DeployWebApp2
displayName: Deploy Web App 2
environment: 'PROD'
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'MyResourceGroup'
appType: 'webApp'
WebAppName: 'webapp2-motionkinetic'
packageForLinux: '$(System.ArtifactsDirectory)/**/WebApp2.zip'
- deployment: DeployFunction
displayName: Deploy Function
environment: 'PROD'
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureFunctionApp@1
inputs:
azureSubscription: 'MyResourceGroup'
appType: functionApp
appName: 'MyFunction'
package: '$(System.ArtifactsDirectory)/**/FunctionApp.zip'
I think the issue is in the yml file itself. What am I doing wrong?
CodePudding user response:
I don't see the FunctionApp.zip before the deploy stage.
Seems no one archived files as 'FunctionApp.zip'(From your YAML I can't see it).
Below YAML will work:
trigger:
- main
pool:
vmImage: 'windows-latest'
stages:
- stage: C
displayName: C
jobs:
- job: xxx
displayName: xxxOfC
steps:
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/FunctionApp.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: D
displayName: Deploy
jobs:
- job: xxx
displayName: xxxOfD
steps:
- task: DownloadBuildArtifacts@1
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureFunctionApp@1
inputs:
azureSubscription: 'testbowman_in_AAD'
appType: 'functionApp'
appName: 'testbowman'
package: '$(System.ArtifactsDirectory)/**/*.zip'
deploymentMethod: 'auto'