Hands on DevOps Coaching provided on AWS and Azure Cloud platforms. please contact at devops.coaching@gmail.com for more info. You can also directly reach out to Coach AK at +1(469) 733-5248
CICD Process Flow Diagram - How to Implement CICD using Azure DevOps?
Azure DevOps is a set of development tools and services offered by Microsoft to facilitate the entire software development lifecycle (SDLC). Azure DevOps is designed to support collaboration among development and operations teams, automate various aspects of the software development process, and enable continuous integration and continuous delivery (CI/CD) pipelines.
What is Continuous Integration?
Continuous integration is a DevOps software development practice where developers regularly merge their code changes into a central repository, after which automated builds and tests are run.
The key goals of continuous integration are to find and address bugs quicker, improve software quality, and reduce the time it takes to validate and release new software updates.
Azure DevOps is widely used for implementing CICD. Azure DevOps can integrate with other tools using Add-ons.
How does Continuous Integration Work?
Developers frequently commit to a shared repository using a version control system such as Git. Prior to each commit, developers may choose to run local unit tests on their code as an extra verification layer before integrating. A continuous integration service automatically builds and runs unit tests on the new code changes to immediately surface any errors.
Benefits of Continuous Integration
Improve Developers productivity
Find bugs early in the software development stage
Deliver products into market place sooner
Improve the feedback loop
What is Continuous Delivery?
Continuous delivery is a software development practice where code changes are automatically prepared for a release to production. Continuous delivery is the next extension of continuous integration. The delivery phase is responsible for packaging an artifact together to be delivered to end-users. This phase runs automated building tools to generate this artifact.
Automating infrastructure setup in Azure Cloud using Terraform and Azure DevOps is a powerful approach to managing your infrastructure as code (IaC). This allows you to define and manage your Azure resources programmatically, version control your infrastructure configurations, and automate the deployment process.
We will be creating a Java based WebApp(app service) in Azure cloud using Terraform and automate the process using Azure Devops Pipelines.
Create storage account, container for Terraform to store state information in Azure cloud remotely.
Create pipeline and add Terraform tasks
Execute pipeline to deploy resources(App service plan and WebApp) in Azure cloud
Verify resources are created in Azure cloud
Confirm if the terraform.tfstate file is updated
Create Resource Group in Azure cloud
Login to Azure portal, Create a new RG, or you can skip this step if you already have existing group.
Create Storage Account in Azure cloud
Create a new resource, type storage account
Click on create
select RG, enter unique account name, select standard as performance, select locally redundant storage
Click on create
Create a container inside the storage account
Select the storage account you just created, click on containers under Data storage
enter a name for the container
Create a pipeline in Azure DevOps
Login to Azure Devops, select Pipelines, select use the classic editor to create a pipeline
Configure Pipeline with tasks
Add Terraform installer task to install Terraform on build agent
Add Terraform task
Configure the task
enter storage account, container, key information as below:
Add terraform tasks to plan, apply
Add Terraform task for plan
change the command to plan from drop down and also select azure subscription from drop down
Add Terraform task for apply
change the command to apply from drop down and also select azure subscription from drop down
Now verify to make sure if we have correct values in each/every task. Now click on Save + Queue.
Click on Save and Run
This confirms that pipeline have successfully created resources in Azure cloud. You can login to Azure portal to see the resources - app service plan and web app.
You can also verify terraform state info which has resources entry for all the resources created
Click on Containers, mytfstatecontainer
Click on terraform.tfstate
Click on Edit to view the content of terraform state file
Clean up resources created in Azure using the pipeline - destroy command
change the command to destroy instead of apply from the drop down
You can either add a new task for destroy or modify to destroy from apply in the existing task.
Now save the pipeline and run the pipeline. check the output of destroy task
How to setup Ansible on Red Hat Linux VM and Integrate with Azure Cloud?
Ansible is #1 configuration management tool. It can also be used for infrastructureprovisioning as well. or You can use Ansible in combination of Terraform which can take care of infra automation and Ansible can do configuration management. We will be setting up Ansible on Red Hat VM in Azure cloud And create some resources in Azure Cloud by using Ansible playbooks.
Ansible Architecture:
The best way to install Ansible in Linux is to use PIP, a package manager for Python.
In this section, you create a local credentials file to provide credentials to Ansible. For security reasons, credential files should only be used in development environments.
mkdir ~/.azure
vi ~/.azure/credentials
Insert the following lines into the file. Replace the placeholders with the service principal values.
Ansible is an open-source configuration management tool that automates cloud provisioning, configuration management, and application deployments. Using Ansible you can provision virtual machines, containers, network, and complete cloud infrastructures.
Automate Azure cloud infrastructure setup using Ansible and Azure pipeline
Integrate Ansible with Azure Cloud
Integrating Ansible with Microsoft Azure allows you to automate and manage your Azure infrastructure using Ansible playbooks and modules. Ansible provides a collection of Azure-specific modules that enable you to provision and configure resources in Azure.
To configure Azure credentials, you need the following information:
Your Azure subscription ID and tenant ID
The service principal application ID and secret
Pre-requisites:
Azure account subscription, click here if you don't have one.
Service principal to create any resources in Azure cloud using Azure cloud shell or Azure CLI
Create Azure Service Principal
Run the following commands to create an Azure Service Principal:
az ad sp create-for-rbac --name <service-principal-name> \
--role Contributor \
--scopes /subscriptions/<subscription_id>
Save the above output in a file as you will not be able retrieve later.
Create an Ansible playbook
Create a simple playbook to create resource group in Azure. Make sure you modify the name of the resource group and location below.
The Azure command-line interface (Azure CLI) is a set of commands used to create and manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation. Azure CLI is Microsoft's cross-platform command-line experience for managing Azure resources.
Azure CLI can be installed by following below steps: