In my current solution, I have two projects: A Net Core 3.1 MVC
project and an Azure Function App
project. Both are hosted in Azure, but in different resources (Webapp in an AppService, and the Function App project has its own Function App resource.
-SolutionName
|_ WebApp Project
|_ WebApp.AzureFunction project
In my current Azure DevOps pipeline, I have defined a build and deploy for the webapp only. How can I add a step that will take only the Azure Function App and deploys it to its respective resource?
EDIT: Based on the answer below, I have edited the yaml. The pipeline succeeds, but the zip for the azure function is empty.
My current yaml file looks like this:
# vm-image, variables, building of webapp removed for brevity.
steps:
- task: DotNetCoreCLI@2
displayName: 'Build Project Azure Function: WebApplicationTest.AzFunction'
inputs:
projects: 'WebApplicationTest.AzFunction.PipelineTest/*.csproj'
arguments: '--output $(System.DefaultWorkingDirectory)/publish_output --configuration Release'
zipAfterPublish: false
- task: ArchiveFiles@2
displayName: 'Archive Azure Function'
inputs:
rootFolderDirectory: '$(System.DefaultWorkingDirectory)/publish_output/'
includeRootFolder: false
ArchiveFile: '$(Build.ArtifactStagingDirectory)/functions/azfunction.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Azure Function: WebApplicationTest.AzFunction.PipelineTest'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/functions'
ArtifactName: 'functions'
#Deploy different artifact to different resources
# Deploy webapp step removed for brevity.
- task: AzureFunctionApp@1
displayName: Deploy to Azure Function
inputs:
azureSubscription: $(azureSubscription)
appType: functionApp
appName: 'WebApplicationTest-AzFunction-PipelineTest'
package: '$(Pipeline.Workspace)/**/azfunction.zip'
I think it needs another step and then take the Azure Function App project from the $(Build.ArtifactStagingDirectory)
package, and deploy it to my Function App resource. What is the best way to do this?