0% found this document useful (0 votes)
8 views

Unit 5 - DO Notes

This document provides a comprehensive guide on building DevOps pipelines using Azure, starting with creating a GitHub account and repository. It introduces Azure DevOps and its components, such as Azure Boards, Repos, Pipelines, Test Plans, and Artifacts, and details the steps to create a DevOps organization and pipeline. Additionally, it outlines the process of creating a Maven-based web application, pushing it to GitHub, and setting up an Azure pipeline for automated deployment.

Uploaded by

gowthamj22it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Unit 5 - DO Notes

This document provides a comprehensive guide on building DevOps pipelines using Azure, starting with creating a GitHub account and repository. It introduces Azure DevOps and its components, such as Azure Boards, Repos, Pipelines, Test Plans, and Artifacts, and details the steps to create a DevOps organization and pipeline. Additionally, it outlines the process of creating a Maven-based web application, pushing it to GitHub, and setting up an Azure pipeline for automated deployment.

Uploaded by

gowthamj22it
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

UNIT 5 – BUILDING DEVOPS PIPELINES USING AZURE

CREATE GITHUB ACCOUNT:


Step1: Open the web site www.github.com on some web browser of your choice. Enter
the sign up option.
Step 2: Enter your email-id. Then create a password for this account. Click the continue
button.
Step 3: Enter the username that will appear as a user name in your GitHub account.
Click on continue.
Step 4: Then a simple puzzle appears, to verify that you are a human being. Just solve it
and continue.
Step 5: Then a code will be sent to your email account (which you have given in step 2),
enter that code to get verified. Then click on continue for free. That's it, the account
gets created.
CREATE REPOSITORY:
 GitHub repository is a kind of folder on GitHub.com which tracks the history of your
code development activity.
 All the team members can access the GitHub repository account and can work in
collaboration with each other.
INTRODUCTION TO AZURE DEVOPS:
 Azure DevOps is a set of development tools and services provided by Microsoft to
help organizations plan, develop, test, deliver and monitor software applications.
 Microsoft has offered Azure DevOps Software as a Service (SaaS) platform for
creating and deploying software. It is a cloud based service that automatically builds
and tests the code projects.
 It consists of a range of services that support the entire Software Development Life
Cycle (SDLC).
 Following are the components of Azure DevOps:
1. Azure Boards: It is a work tracking and project management tool within azure
DevOps. The azure boards is designed to help development teams plan, track and
manage their work throughout the Software Development Life Cycle (SDLC). It
provides the centralized platform for managing tasks, user stories, features and
other work items.
2. Azure Repos: Azure repos is a version control system offered by Microsoft’s
DevOps services. It provides a centralized platform for managing and tracking
changes to source code during software development process. It supports both Git
and Team Foundation Version Control (TFVC), bitbucket cloud and subversion. so
that the team can choose the version control system that best meets their needs.
3. Azure Pipelines: The azure pipeline is a Continuous Integration (CI) and
Continuous Delivery (CD) service provided by Microsoft as a part of DevOps. This
tool basically helps the development team to automate the building, testing and
deployment of their software applications. At the end, the high quality code can be
produced in a faster and more reliable way. Azure pipeline allows to define build
and deployment pipelines as code, which can be triggered automatically when
code changes are committed. The Azure pipelines support a wide range of
programming languages, platforms and tools making it highly adaptable.
4. Azure Test Plans: This feature helps to manage and execute the test cases, track
the test results and collect the feedback. It is a key part of Azure DevOps, a suite
of tools that help teams manage their software development and testing processes.
5. Azure Artifacts: Azure artifacts is a package management tool that support for
Maven, npm, NuGet and Python packages. It helps manage dependencies and
artifacts required for our software projects.
CREATE DEVOPS ORGANIZATION:
 Azure DevOps organization helps in handling multiple projects efficiently without
any ambiguity.
 Organization: The DevOps organization refers to azure DevOps account name. It
contains multiple projects.
 Project: The users create the separate projects for development purposes. They
control the access, split the code, tests and pipelines to keep them within the
assigned project. A project can be either public or private, with Git or team
foundation server as the version controlling system.
 Once the registration is complete, you will gain a dedicated organization URL in the
following notation:
dev.azure.com/<Organization_Name>
 Users can manage all their projects and use the DevOps services by visiting this
URL.
 Steps to create new organization
Step 1: Sign in to azure DevOps.
Step 2: Select new organization.

Step 3: Give a suitable name to your organization and confirm the information.
Then select Continue.
Step 4: The pop-up window of processing will appear.

Step 5: Once the organization is created, it will prompt you to enter the Project
name. Enter any suitable project name and set the visibility to Public or
Private. Normally for small development purposes or for learning purposes we
keep the visibility as Private. Then click on the Create Project button.
The window will appear highlighting the project name. Now we can create Repos
and Pipeline for this project.

AZURE PIPELINE:
 Azure pipeline is an automated set of processes that help. developers to compile,
build and deploy codes on other computational platforms.
 It is a continuous integration tool like Jenkins. The purpose of this tool is that there
should not be manual intervention, all the changes are automatically executed in the
project.
 This pipeline can be used with many application types such as Java, Go, Python,
JavaScript, Node.js, .Net, C++ and Xcode.
 Tasks are the building blocks that define pipeline automation. A task is a packaged
script or procedure that is abstracted as a set of inputs. When a job is executed, all
tasks defined within it are executed sequentially.
 This pipeline is based on the strong foundations of CI/CD pipelines which
consistently test, build and deploy. They also perform constant deliveries
automatically by continuous testing and deploying the codes to the desired targets in
the project.
 The pipeline is broken down into following categories
1. Source control
2. Build tools
3. Package creation
4. Configuration management
5. Monitoring
 Continuous Integration (CI): Continuous Integration (CI) is the process of
automating the build and testing of code, every time a team member commits
changes to version control. All the changes made by the development and testing
team are committed to the master branch to bring out a clean and unambiguous
code.
 Continuous Development (CD): Continuous Delivery (CD) is the process to build,
test, configure and deploy from a build to a production environment.
Advantages:
 Reliability: Monitoring and logging practices help you stay informed about
performance in real-time.
 Improved Collaboration: With DevOps and a single combined platform developers
and operation, teams collaborate easily. They are no longer isolated from-each other
and share responsibilities and feedback.
 Rapid Delivery of Code: DevOps combines tools and all processes in the cloud so
starting from developing the apps and testing it in the cloud by using automated
tools and deploying as soon as code commit happens. This enables rapid delivery.
 Accessibility: Azure DevOps users get access to new features every three weeks.
Microsoft is transparent.
 Scaling: Infrastructure as code helps you manage your development, testing and
production environments in a repeatable and more efficient manner.
 Security: Automated compliance policies, fine-grained controls and configuration
management techniques can define and then track compliance at scale.
 Flexibility: If a DevOps team doesn't want or need the full suite of services, they can
acquire them independently.
CREATE A PIPELINE:
 Pipeline allows us to build and deploy the application automatically. If we commit
any changes to the code, then those changes are also reflected automatically to the
final output.
 We will first build a sample application and then create a pipeline for building and
deploying that application on the web server.
Build a Sample Code:
 We will discuss how to create a Maven based Web application using Eclipse.
 This is a simple web app, in which we have simply written an index.jsp file,
displaying some messages.
Stage 1: Create a Maven Web Application Project
Step 1: Click on File->New->Maven Project. Following pop-up window will appear -

Just click next button without selecting any archetype over here. Another window will
appear as given below - Select the maven-archetype-webapp
Then click the Next button. Provide the Group Id and Artifact Id as per your choice.
Click the finish button.
Step 2: In the project explorer window, right-click on the project select properties->
Java Build Path.

Click on libraries path and click on JRE System Libraries and edit it by giving the
path of JDK.
Click on Finish button. Then click on apply and close.
Step 3: The project structure of your Maven web application project.

Just open the index.jsp file and edit it. I have edited it as follows-
index.jsp
<!DOCTYPE html>
<html>
<body>
<h2> Welcome Anuradhal!</h2>
<h2> Enjoy!!</h2>
</body>
</html>
Step 4: Now edit pom.xml by adding some dependencies.
Add Jakarta Servlet dependency in the pom.xml file. The dependency code can be
obtained-from mvnrepository.com. The code for the dependency is as follows -
<!-- https://mvrepository .com/artifact/jak arta.servlet/j akarta.servlet-api -->
<dependency>
<groupId>jakarta. servlet </groupld>
<artifactld> jakarta.servlet-api</artifactld>
<version>6.0.0</version>
<scope > provided</scope>
</dependency>
Step 5: This application can be run using Maven Build.
Step 6: Create a GitHub repository named My WebApp and push this application in
the Git Hub repository.
Stage 2: Push Maven Web App on GitHub
Step 1: Sign in the Github.com by entering your username and password.
Give the repository name. Note that this name must be the same name as of your
Maven project (we have created in stage1). Click on New and then type the name of
the repository

Step 2: Now click on Settings -> Developer Settings, click on Personal access
tokens.

click on generate new token in order to create a token. This token is generated so
that any third party application can access this repository without re-entering the
login name and password.
I have given the token name as mytoken and no-expiration to this token. Selected
the repo checkbox.

Then click on the Generate Token button. A token will get generated.
Step 3: Now in the eclipse IDE, from the menu bar, click on Window->Show view-
>other. Select the Git Repositories.
Step 4: On github.com, just copy the URL link of your repositories.

Step 5: Now, inside the eclipse, click on Clone a Git repository.


Immediately a pop up window will appear as follows -

Click the next button.


Click the Finish button.
Right click on the project click Team-> Share Project.
Click on the Finish button. Now from menu bar of eclipse, select Window->show
view->other. Select the Git Staging. Now drag the index.jsp and pom.xml file from
Unstaged Changes area to Staged Changes.

Now type some commit message and click on Commit and Push.

Then a pop up window will appear on which as a user-name we have to enter the
Github’s user email id. And as a password it has to copy the Personal access token
from Github.
Thus the copied token is pasted as a password in eclipse. Check the checkbox Store
in Secure Store. Then click Login button.

Then push the app

Step 6: Now, in the web browser just refresh GitHub.com. we can now see our web
application on GitHub.
That’s it, we have pushed our application on GitHub.
Modify Azure-Pipelines.yaml File:
Stage 1: Creation of Azure Web App Service
Step 1: Login to the microsoft azure cloud portal. You can log-in using GitHub account
also. Click on app-services.

Step 2: Then select Create->Web App. The create web app page will appear. Enter the
name of the resource group of your choice. Then give any suitable web app name.

Step 3: Select the runtime stack as Java, as I have to deploy a Java based web
application. The tomcat container is used to run the Java application. Hence selected the
Apache Tomcat 9.0. The operating system on which the web app is running is Linux.
Rest of the parameters are kept as default. Click the on Review + Create button. Then
click on Create.
This will start the deployment process. You will get deployment successful message as
follows -

Step 4: Now click on the Go to resource button. We will get the default domain name.
Here I will get the domain name as noonewebapp.azurewebsites.net
Stage 2: Create Azure Pipeline using Azure DevOps
Troubleshooting: When we start creating a azure pipeline using azure DevOps, normally
we get the error “No hosted parallelism” error. To fix this error, the solution is simple,
visit https://aka.ms/azpipelines-parallelism-request site. Fill the details as asked in the
form, for betterment fill the form once with private projects and again with a public
project option selected. Within one or two days, Microsoft grants you the permission.
This arrangement is for security reasons. That’s it.
In this application, we have simply written an index.jsp page, displaying some header
messages.
This pipeline will build our web application and deploy it automatically to the web app
service, created in stage 1 (given above).
Step 1: Open the azure DevOps page and create a New Project. And give a suitable
name to your project. I have given the name SampleWebApp.
Step 2: Click on repos, to select the existing repository.
Click on the Import repository option. Now go to GitHub.com and copy the URL of the
repository of your choice. I have created a simple Java Web application in the repository
named MyWebApp. I will copy the URL.

and paste it in the Clone URL text box of azure DevOps. Then click on the Import
button.

Step 3: Now click on Pipelines and click on Create Pipeline. Then select the repository.
Then configuration page appears. Select Maven Package Java Project Web app to
Linux on Azure.
Step 4: Select the subscription (Free Trial). This is the subscription which you have
selected on your Azure cloud services.

Once you click Create button. It will prompt you to enter microsoft username to login.
Once you login, It will allow to select the web App name that comes automatically on
Azure DevOps. Click on Validate and Configure button. It will then start generating the
yaml file automatically for your web app. Note that, everything is automatic over here, we
simply need to configure our repository.
Step 5: The yaml file named azure-pipelines.yml gets generated. Just edit the location
of pom.xml as My WebApp/pom.xml Just click the Save and Run button. The yaml file
is as follows
trigger:
- master
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: ‘b2e71b79-27af-4ade-9493-33852b2e0ae8’
# Web app name
webAppName: ‘NoOneWebApp’
# Environment name
environmentName: ‘NoOneWebApp’
# Agent VM image name
vmImageName: ‘ubuntu-latest’
stages:
- stage: Build
displayName: Build stage
jobs:
- job: MavenPackageAndPublishArtifacts
displayName: Maven Package and Publish Artifacts
pool:
vmImage: $(vmImageName)
steps:
- task: Maven@3
displayName: ‘Maven Package’
inputs:
Set the exact
location of your
mavenPomFile: ‘MyWebApp/pom.xml’
- task: CopyFiles@2
displayName: ‘Copy Files to artifact staging directory’
inputs:
SourceFolder: $(System.DefaultWorkingDirectory)’
Contents: ‘**/target/*.?(war|jar)’
TargetFolder: $(Build.ArtifactStagingDirectory)
- upload: $(Build.ArtifactStagingDirectory)
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded ()
jobs:
- deployment: DeployLinuxWebApp
displayName: Deploy Linux Web App
environment: $(environmentName)
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: ‘Azure Web App Deploy: NoOneWebApp’
inputs:
azureSubscription : $(azureSubscription)
appType : webAppLinux
appName: S(webAppName)
package: ‘$(Pipeline.Workspace)/drop/**/target/*.?(war|jar)’
Step 6: It will start working in two stages Build Stage and Deployment Stage.

On completion of Build Stage we can see the pipeline as follows-

Step 7: For the deployment stage, it will ask for permission. Just permit it by clicking on
it and then clicking on the View button.
After granting the permission, the deployment stage starts. On successful completion of
deployment stage we get following output.

Thus both the build stage and deployment stages are completed.

Step 8: Now, go to azure cloud and click on the URL to get the output as follows - Note
that we have to add the name of the GitHub repository to the domain name to get the
output.
Step 9: Just edit index.jsp in our repository of azure DevOps.

Again build and deploy the azure DevOps pipeline, we will get the changes reflected on
the web page.

Thus, azure DevOps and azure cloud web service allows us to automate the building and
deployment of the web application.

You might also like