Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

AZURE DevOps – CI CD - Build and Release Pipeline – Azure Function

Article:
Viewed:  643 
Posted On:  02/10/2019 09:58:44 
Learn Azure DevOps CI & CD - Azure Functions App 

 

In this article, I am going to show how we can make a CI & CD Build and Release Pipeline for an Azure Function.

Below are the steps

  • Code Repository = Azure Repo Git
  • Build Pipeline
  • Release Pipeline
  • Finally Azure Function in Portal with CI & CD J

1.png

Image 1.

Pre-requisites: 

    An existing Azure Function App

2.png

Image 2.


Create an Azure Function App through Code:

Open Visual Studio 2017-> New -> Project
Select Cloud => Azure Functions

3.png

Image 3.

Click Ok.

4.png

Image 4.

Select Http trigger Function. Click OK.


5.png

Image 5.

Leave everything as default. I just renamed the Function Name to (SayHelloFunction).

In addition, if we pass Name as query string then "Hello From Noida – Welcome – {Name}" Message will return.

Check-in Your Code to Azure Repos:

Now our Visual Studio Code is ready.

Next step is to create a Project in Azure. Open https://dev.azure.com

Login with your credentials.

Create an Organization here if you do not have.

I have rahsaxen1  (Organization)


6.png

Image 6.

Click on + New Project.


7.png

Image 7.

Click on Create.

Now we will commit our code into Azure Repos Git.

So Click on Repos from left side Menu:


8.png

Image 8.

 

Copy Azure Repo Git URL:
https://dev.azure.com/rahsaxen1/_git/RAHULTestFunctionAppCICD

Now open your Function App code Location:

We will commit our code into Azure Repo Git through Git Command:


9.png

Image 9.

Type cmd.exe and hit Enter:
Command window will open.

Execute below Git Command:

> git init
> git add .
> git commit -am "Add your app"
> git remote add origin <git Repo Url>
> git push -u origin –all

10.png

Image 10.

Now check you Azure DevOps Project (Repos)

11.png

Image 11.

Build Pipeline For Azure Function:

Now click on Pipeline from Left Side Menu:

Pipeline -> Build -> New Pipeline

12.png

Image 12.

13.png

Image 13.

14.png

Image 14.

Click on Continue. Now select a Template.

15.png

Image 15.

Select ASP.NET Core here and Apply. Some default job will add.

16.png

Image 16.

Keep everything as default. Select Publish:

In Publish Job -> DeSelect Publish Web Projects because, if this option is enabled the Publish task will look for a web project in the repository and run the publish command.

Now select Triggers option.

17.png

Image 17.

Make Enable Continuous integration.

18.png

Image 18.

Save it.

19.png

Image 19.

Now Queue your build.

20.png

Image 20.

21.png

Image 21.

Click on Run.

22.png

Image 22.

23.png

Image 23.

Build Pipeline has been successfully completed. Now time to create Release Pipeline:

Release Pipeline for Azure Function:

Select Pipeline -> Release

24.png

Image 24.

Select Azure App Service Deployment template and Apply.

25.png

Image 25.

26.png

Image 26.

27.png

Image 27.

Here Select Azure Subscription, App Type and App Service Name.

28.png

Image 28.

29.png

Image 29.

Save it and Now click on "Add an Artifact"

30.png

Image 30.

Click Add. In addition, Save it. J

Make sure Continuous Deployment is enabled.

31.png

Image 31.

 32.png

Image 32.

33.png

Image 33.

Now check in Azure Portal: https://portal.azure.com

Navigate to Function App:

34.png

Image 34.

Function, deployed successfully J

Now Copy Function URL and browse it.

35.png

Image 35.

36.png

Image 36.

37.png

Image 37.

Function Access level is Function. So while browsing we have to pass function code as well.

Now make any change in your Visual Code and commit your changes. Automatic Build will trigger and new deployment will happen.

38.png

Image 38.

Commit your Changes.

39.png

Image 39.

Now check you Build Pipeline.

40.png

Image 40.

Now check Release Pipeline:

41.png

Image 41.

Now check your function output by hitting function URL:

42.png

Image 42.

Over all summary of this article:

  • Configure Build Pipeline in Azure Devops
  • Configure Release Pipeline in Azure Devops
  • Enable Continuous Deployment in Azure Devops
  • Enable Continuous Integration in Azure Devops 

Thanks J 

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us