0
votes

I have a .Net project created in Visual Studio for Azure function App. The function app should be deployed into azure resource group.

Manually I can deploy it with the following commands.

To build:

dotnet publish -c Release

To deploy:

az login
az account set --subscription <id>
az functionapp deployment source config-zip -g <resourceGroup> -n <functionName> --src publish.zip

I want to automate this process through Azure DevOps, as when I push this code (vs project) into azure repository, I want to build this automatically and deploy through CI/CD.

I have been searching this, but was unable to find any helpful resource.

Can someone provide me step by step guide on this with providing examples to create .yml files if required??

1

1 Answers

0
votes

You need to create a pipeline to deploy the function App. You can follow this blog to see how to configure and deploy the function to Azure.

For ex, follow the docs,

pool:
      vmImage: 'VS2017-Win2016'
steps:
- script: |
    dotnet restore
    dotnet build --configuration Release
- task: DotNetCoreCLI@2
  inputs:
    command: publish
    arguments: '--configuration Release --output publish_output'
    projects: '*.csproj'
    publishWebProjects: false
    modifyOutputPath: false
    zipAfterPublish: false
- task: ArchiveFiles@2
  displayName: "Archive files"
  inputs:
    rootFolderOrFile: "$(System.DefaultWorkingDirectory)/publish_output"
    includeRootFolder: false
    archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
    artifactName: 'drop'