How to Build an Azure Pipeline (Build/Release) from Scratch

choubertsprojects

VPN offers!

1. NordVPN

2. Surfshark

3. ExpressVPN

Microsoft Azure offers a wide range of cloud services and tools, but it’s not always easy to get started. This post will teach you how to build an Azure Pipeline from scratch so that you can follow along with our demo for this blog post

The “build pipeline in azure devops” is a build process that allows developers to create, test and release software. This process utilizes the Azure DevOps service. The article will provide you with step-by-step instructions on how to build an Azure Pipeline from scratch.

How to Build an Azure Pipeline (Build/Release) from Scratch

Software must be developed, tested, and deployed in a live environment. To do so, developers and DevOps create CI/CD pipelines, also known as build/release pipelines, which automate much of this effort.

Developers, DevOps teams, and others may use a pipeline to create and release trustworthy code. In the Microsoft world, Azure DevOps has a tool called Azure Pipelines that may be used to design a pipeline.

Azure Pipelines enables you to conduct builds, tests, and distribute code to multiple development and production environments automatically. But what if you’ve never heard of Azure DevOps or a pipeline, or if you’ve never constructed one with Azure DevOps before? If that’s the case, you’ll like this Azure Pipelines lesson.

Thanks to Microsoft Azure Technical Trainer Peter De Tender for his assistance with this post.

Overview of the Project

This is a project article on how to develop a project or put a solution in place. Each segment will be a series of stages that build on the one before it.

This project will teach you how to build your own Azure DevOps pipeline from the bottom up. You’ll learn how to invoke builds from a Git version control commit, run tests automatically, and eventually deploy packages to environments. You will have an example e-commerce application deployed as an Azure WebApp at the conclusion of this project.

It should take you 30 minutes to finish this project.

You will not be charged on your Azure account if you follow this Project and promptly delete the resources produced. Remember to take them out!

Target Market

This project will walk you through the steps to create your first Azure Pipeline using the Azure DevOps web UI. If you’re new to Azure Pipelines, this project will teach you a lot, but if you’ve previously constructed your own pipelines or are an Azure Pipelines expert, you won’t learn nearly as much.

Environmental Conditions

If you’re going to proceed through this Project step by step, make sure you have the following items:

Getting Started with Azure DevOps

Because we’re beginning from scratch, you’ll first construct the organization, which is the “foundation” object that contains all Azure DevOps capabilities and services. All projects are saved in the organization, which you’ll learn how to establish in the following part.

  1. Browse to All services in the Azure Portal, search for DevOps, and then pick Azure DevOps. Below is a list of things to anticipate. This will bring up the Azure DevOps blade, as seen below.

Dashboard for Azure DevOpsDashboard for Azure DevOps

2. After that, go to My Azure DevOps Organizations and log in with your Azure credentials. As seen below, you will be sent to a screen where you may form a new organization. Click the blue Create new organization button after you’ve arrived.

Create a new organization page for Azure DevOps.Create a new organization page for Azure DevOps.

3. Give the group a name on the next page. Check the Azure DevOps organization naming conventions if you’re having trouble utilizing a certain name. On this page, you may also choose the Azure region that is nearest to you. Click Continue when you’re finished.

Page for creating an Azure DevOps organizationPage for creating an Azure DevOps organization

Your Azure DevOps organization has now been formed!

Creating a DevOps Project in Azure

The next step is to create a project. A project is a container for the pipeline you’ll be building, as well as any artifacts and information related to a certain service or piece of software.

You may construct a project in the same way that you created an organization in Azure DevOps. If you followed the steps correctly, you should now be on the project creation page shown below.

  1. Give your project a name in the Project name area on the project creation page. You’ll use devopsdemo, an Azure DevOps project, for this project.
  2. Click the + Create Project button to confirm the project’s creation.
  3. Leave the Visibility to Private for the time being. This prevents your project from being visible on the internet. Non-project members and non-signed-in users have read-only access to the project’s assets in a public project.

Page for creating Azure DevOps projectsPage for creating Azure DevOps projects

Your Azure DevOps workspace (project + organization) is now ready to use. If you’ve been following along, you should now have an Azure DevOps organization named pdtitws123 and a project named devopsdemo inside of it.

Azure DevOps Overview of the ProjectAzure DevOps Overview of the Project

Creating a DevOps Build Pipeline in Azure

You can now setup a build pipeline within Azure DevOps once you’ve set up an organization and project. All of the magic occurs in the pipeline. It’s here that you’ll make builds to do things like compile code, import dependencies, and more.

  1. Select Pipelines then Builds from the dashboard.

Builds for Azure DevOpsBuilds for Azure DevOps

2. A notification will appear stating that no build pipelines have yet been discovered. To start building the build pipeline, click New pipeline.

There are currently no build pipelines bound. A new pipeline is being built.There are currently no build pipelines bound. A new pipeline is being built.

3. You will then be asked to specify the location of your code. The code for this project is kept in a GitHub repository. Choose GitHub. This is where the code will be kept, as well as the triggers for starting the build.

Choosing a source for version controlChoosing a source for version control

4. When you click on GitHub, you’ll be asked to enter your GitHub credentials, as seen below. Remember to establish an empty GitHub repo as described in the Prerequisites section of this article before starting this step!

Giving your GitHub credentialsGiving your GitHub credentials

5. Next, confirm the authorization request for Azure Pipelines. This grants Azure DevOps access to your GitHub repositories.

Adding GitHub access to Azure PipelinesAdding GitHub access to Azure Pipelines

Adding a GitHub Repository to the Build Process

Link a GitHub repo to the build pipeline after giving Azure DevOps authorization to your GitHub account.

  1. Choose the empty GitHub repository you created for this project.

GitHub repository with no contentGitHub repository with no content

2.  Allow the project to read, write and check source code from the repository you selected earlier. Then confirm this process by clicking Approve & Install.

Verify Azure DevOps integration with Github.Verify Azure DevOps integration with Github.

3. If you click confirm, an error will appear, as seen below. Because the GitHub Repo specified is empty, this error will occur.

When a GitHub repository is empty, an error occurs.When a GitHub repository is empty, an error occurs.

Your GitHub repository will now be connected to your Azure DevOps build process.

You don’t have to start from scratch every time you wish to connect a GitHub repository to an Azure DevOps build process.

Adding Code to a Sample GitHub Repository

Without certain code in the GitHub repo, the Azure DevOps build process would not execute. At this point, the code doesn’t really matter. We’ll clone some code from an existing repo to get some code into the repo. I have all the source code for publishing an e-commerce example application on Azure WebApps in this repo.

A prototype e-commerce application named SimplCommerce will be included in the sample code for this repo. This is a dotnetcore open-source project that is more realistic than the conventional “hello world” project.

  1. Go to this GitHub repository and select Import code, as seen below.

Create a GitHub repository called myfirstrepo.Create a GitHub repository called myfirstrepo.

2. Use http://github.com/007FFFLearning/SimplDev as the previous repository’s clone URL and click on Begin import.

Authenticating the repo clone URLAuthenticating the repo clone URL

Refresh the Azure DevOps Pipeline window after the repo import process is complete, and you should be able to proceed immediately.

YAML Build Pipeline Inspection and Viewing

You’ll be at the Review phase of the pipeline building process at this time. A YAML representation of the build pipeline will now be shown to you. This YAML file is generated automatically based on the recognition of the source code language in this project, which is dotnetcore.

The pipeline YAML is one of the key advantages of Azure DevOps. Many other DevOps solutions need you to manually create a pipeline file.

Examining the pipeline YAMLExamining the pipeline YAML

Running the Azure Build Pipeline by Hand

A commit to source control often triggers the build in a continuous integration (CI) pipeline. You may, however, manually start the construction process. Let’s manually start a build process and observe what occurs.

If you’ve been following along, you should have reached the stage where you can click Run to start the build process. As you can see in the picture below, this will start the pipeline construction process.

Starting the pipelineStarting the pipeline

After a few seconds, you’ll see that the process for macOS is running, as illustrated below. As each job and task in the pipeline executes, the build pipeline will deliver information in real time.

The macOS build agent is in use.The macOS build agent is in use.

As seen below, the build pipeline will then repeat the procedure for the other operating systems (in this case). Depending on how the YAML file was created, the stages will differ significantly.

The Linux build agent is in use.The Linux build agent is in use.

You’ll be welcomed with green checkmarks after the construction is finished, as seen below. This image shows that each platform construction completed properly.

Running a pipeline successfullyRunning a pipeline successfully

You’ve just finished setting up an Azure DevOps build pipeline!

Creating a DevOps Release Pipeline in Azure

The build pipeline has been established, which is a significant step forward. You’d be well on your way to having a fully automated pipeline if you stopped here. But we’re not finished yet! The ultimate purpose of software is for it to be deployed and used by consumers. It’s time to use a release pipeline to automate a release as well!

A release pipeline releases a build artifact, which is a product of the build process, to one or more environments. You’ll utilize a release pipeline in this project to push code from a GitHub repo to an Azure Web App.

  1. Click Pipelines and then Releases in Azure DevOps.

Menu item is released.Menu item is released.

2. Select New, followed by New Release Pipeline. This starts the wizard for creating a new release pipeline.

New menu option for the release pipelineNew menu option for the release pipeline

3. Select Azure App Service Deployment from the right-hand template list. You’ll find a variety of templates to help you save time while designing future release pipelines.

Choose a deployment template for Azure App Service.Choose a deployment template for Azure App Service.

4. Give the Stage Name a brief description. Release tasks will be included at this stage. Use the name Deploy to webapp for this project.

Indicate the stage name.Indicate the stage name.

The release process should now resemble the image below.

Stage was built.Stage was built.

5. Select 1 job and 1 task in the Stages box. This is where you will ultimately supply the Azure Web App environment parameters that you will utilize for the actual deployment.

6. You’ll need to specify a few parameters on this page as part of the Azure App Service deployment template.

  1. In this case, the stage name is Deploy-to-Webapps2.
  2. Select your Azure subscription and confirm with Authorize.net (needs credentials)
  3. Web application on Linux
  4. App Service Name — the name of the web app you built before.

Parameterizing the templateParameterizing the template

7. When you’re finished, go to the top menu of your Azure Pipeline project and choose Pipeline, as shown below. This will take you back to the main page, where you may finish the next step of defining the artifacts.

Returning to the pipelineReturning to the pipeline

The Azure DevOps Release Pipeline: Adding Artifacts

There are several components that must be distributed as part of a release process. Artifacts are the term for these objects. Simply said, artifacts are components of your application that may be deployed. Artifacts created by a variety of artifact sources may be deployed using Azure Pipelines.

Let’s look at how to add artifacts to the release process in this part.

  1. Select Add an Artifact from the Pipeline screen.
  2. Because you’ll be deploying the output of the build pipeline you constructed previously, the Source Type is already set to Build. In the Source (build pipeline) dropdown, choose the build pipeline you built previously.
  3. When you’re ready, click Add to save your settings.

Introducing an artifactIntroducing an artifact

4. Finally, in the top right corner of the screen, click the Save button to save the release pipeline.

Putting together the Azure DevOps Release

You’ll start making releases after the release pipeline is set up. A release refers to a certain pipeline run. Consider the release pipeline as a template, with unique instances of it acting as releases. After you’ve created a release, it’s time to deploy it.

To make a release, first:

  1. As illustrated below, click the Create Release button in the top right corner of the window.

Overview of the new release pipelineOverview of the new release pipeline

2. You’re not going to do anything fancy, so accept the settings and click Create on the Create a new release page. At this point, you just have a single stage and a single version of the build artifact to deploy.

Make a new item for release.Make a new item for release.

3. You will get a notice (the green bar) indicating the release has been made within a few seconds, as seen below. Now click Release-1, which will take you to the release process’s specifics.

Select Release-1.Select Release-1.

You’ve completed a release and are now ready to deploy it!

Deploying a Release Manually

A build release is a collection of instructions for deploying a build. You’ve taken care of everything. Now it’s time to put those instructions into action and deploy code to a target environment.

While working on the Release-1 release you previously created:

  1. Choose the Deploy to webapp stage and click the Deploy button. The status will change to In process when you do so, as illustrated below. The release is now taking the source code from the prior build workflow and delivering it to the Azure WebApp instance.

    This step will start a task in the backend that will copy source code and execute the real release cycle on an agent.

Stage of developmentStage of development

2. While the stage is running, click on it. Any logging information will be shown in the console output section.

Job log showing Stage of developmentJob log showing Stage of development

When finished, the stage should be visible. As seen here, I was successful.

Stage completedStage completed

The release should have completed successfully, and you should now have a web app published to an Azure Web App!

Examining the Finished Azure WebApp

Check out the results of your effort now that the whole procedure is complete.

  1. Log in to the Azure Portal, go to the Azure WebApp you chose as the target in the release process, and copy the URL as shown below.

In the Azure interface, look for the Azure App Service URL.In the Azure interface, look for the Azure App Service URL.

2. Paste the URL into a browser, along with the Azure Web App’s URL. The e-commerce example application should now load in your browser, identical to the main page below.

The deployed application's home pageThe deployed application’s home page

You’ve finished everything! You now have a fully automated Azure web app that was launched from a GitHub repository!

Organizing

You now have a new Azure DevOps organization, project, build pipeline, release pipeline, and release if you followed through with this project. When you’re through testing, be sure to delete the original organization you formed so you don’t get paid for Azure resources.

To do so:

  1. Return to your Azure DevOps main workspace.
  2. In the bottom left corner, choose Organization settings.
  3. On the Overview screen, under Delete organization, click the Delete button at the bottom of the page.
  4. After typing the organization’s name, click Delete. This should get rid of everything you just did.

Observations

You’ve built a whole CI/CD pipeline from scratch in Azure DevOps if you followed the guidelines in this Project. You should now have a solid understanding of how this procedure works.

Although Azure Pipelines may go much deeper than what you learned in this project, you should now have a good understanding of the whole process.

The “create release pipeline in azure devops using yaml” is a guide that will help you build and release an Azure Pipeline from scratch. The article will walk through the entire process, including how to create an Azure DevOps project, create a deployment pipeline, and deploy your code to production.

Related Tags

  • what is the azure cli command to create a new pipeline named first-pipeline
  • build pipeline vs release pipeline
  • azure pipeline template
  • azure pipelines
  • azure build pipelines