To create a CI pipeline YAML file for deploying an Azure Functions project using the isolated worker model, you need to ensure that the build process correctly handles the .azurefunctions folder and the DLLs. Below is a sample YAML configuration that you can adapt for your needs:
trigger:
branches:
include:
- main
pool:
vmImage: 'windows-latest'
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration Release'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
projects: '**/*.csproj'
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/functionapp.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/functionapp.zip'
ArtifactName: 'functionapp'
publishLocation: 'Container'
Key Points:
- Restore: The pipeline restores the NuGet packages required for the project.
- Build: The project is built in Release configuration.
- Publish: The output is published to a specified directory, which should include the
.azurefunctionsfolder and the necessary DLLs. - Archive: The published files are archived into a zip file for deployment.
- Publish Artifacts: The zip file is published as an artifact for later use in the release pipeline.
Ensure that your project structure aligns with the expected output for Azure Functions, particularly that the .azurefunctions folder and DLLs are correctly included in the published output.
If you are experiencing issues with the DLLs not copying to the wwwroot/bin folder, ensure that your project file is configured to output the necessary files correctly during the publish step.
References: