Tuesday, May 28, 2019

Deploying Azure Function App with Azure DevOps - part 1

Azure function is a small piece of code in cloud which you can write as a solution for the problem without worrying about an application or infrastructure to run it. Azure Functions let you develop server less application with several development languages.This post will discuss how to create an Azure function project with visual studio and package the function application using Azure DevOps build.


  • Azure function tools available in the Azure development workload of Visual Studio 2017 or later version. So, include the Azure development workload in Visual Studio.
  • Open visual studio IDE
  • Select File –> New
  • In the new project dialog box, Select Azure functions project
  • Give project name and  location and click on create button

  • Then a window will prompt where you can select the triggers.I select Http trigger.


1 - Here you can select framework of the function.There are two options, Azure Functions (>NET Core) and Azure Functions ( .NET framework)
2 - Select the function storage type from this drop down .None,Storage Emulator and Browse options available in the drop down
3 - Select the access right from the drop down. There are Functions,Anonymous and Admin values.

  • After select the values click on OK button to create a Function project
  • You have created an Azure function project.Let's commit the changes to the Azure DevOps project repository.
  • Now you can find the source code in the repo.Now we are ready to create an Azure DevOps build pipeline.
  • Go to pipelines and select build
  • Create new build using the classic editor
  • Add tasks to build and archive an Azure Function App.



1 - NuGet tool installer task is using to install required NuGet to build server before execute NuGet restore task.

2 - NuGet restore task is using to install required NuGet references to the  project

3 - Visual Studio Build task is using to build the solution with MSBuild

            a -  Select solution file

            b - MSBuild arguments

                  /p:DeployOnBuild=true
                  /p:DeployDefaultTarget=WebPublish
                  /p:WebPublishMethod=FileSystem
                  /p:publishUrl="$(Agent.TempDirectory)\WebAppContent\\"

Add two variables in variables tab to add configurations and platforms. So Let's add two variables as BuildConfiguration or BuildPlatform in the variable tab with release as BuildConfiguration value and anycpu as BuildPlatform value.

4 - Archive files task is used to add root folder or file content to archive


         a - Content of this location will be added to archive
         b - Select the archive type
         c - Specify the name of archive file to create. We are going to create a archive with build definition id as name.
5 - Publish Artifact file is used to publish the build artifacts to Azure pipelines or file share

  • Trigger a build to publish function app as archive. After build succeed go to Artifacts. You should be able to see the zip file with build id as name.



We have discussed how to create an Azure function app and publish it to archive using Azure DevOps build pipeline.In the next post you would be able to learn how to deploy this function app to Azure App Service.

No comments:

Post a Comment