This blog gives a step by step walkthrough of implementing CICD in an Azure environment using YAML and pipelines.
This blog talks about technologies that are part of the Azure DevOps environment. If it’s something in which you have an interest or you want to learn it then you can visit our previous blog to know more about the [AZ-400] Microsoft Azure DevOps certification.
What Is An Azure DevOps Environment?
An environment is a collection of resources that can be targeted by deployments from a pipeline. Environments can include Kubernetes clusters, Azure web apps, virtual machines, databases. Typical examples of environment names are Dev, Test, QA, Staging, and Production.
The advantages of using environments include the following.
- Deployment history — Pipeline name and run details are recorded for deployments to an environment and its resources. In the context of multiple pipelines targeting the same environment or resource, the deployment history of an environment is useful to identify the source of changes.
- Traceability of commits and work items — View jobs within the pipeline run that target an environment. You can also view the commits and work items that were newly deployed to the environment. Traceability also allows one to track whether a code change (commit) or feature/bug-fix (work items) reached an environment.
- Diagnose resource health — Validate whether the application is functioning at its desired state.
- Permissions — Secure environments by specifying which users and pipelines are allowed to target an environment.
How To Setup DevOps Environment In Azure
- Step 1: Sign in to our Azure DevOps organization and navigate to our project.
- Step 2: In our project, navigate to the Pipelines page. Then choose Environments and click on Create Environment.
- Step 3: After adding the name of an environment (required) and the description (optional), we can create an environment.
- Step 4: Resources can be added to an existing environment later as well.
- Step 5: Then we can get started by add this newly added environment into the YAML code.
- Step 6: Once after we added that environment into the YAML pipeline, we need to start running it.
- Step 7: We can see the multiple environments as part of this YAML, basically, we are adding the CICD into the YAML file.
- Step 8: From the above environment, we can see the below deployment happened successfully
- Step 9: Now after this we can log in to the Azure portal and then check if the below deployment is successful or not.
- Step 10: Now when we click on the below URL, we can see the basic build and deployment of the “HELLO WORLD” application as a sample NodeJS.
Using Approval Checks
We can also manually control when a stage should run using approval checks. You can use approval checks to control deployments to production environments.
Checks are a mechanism available to the resource owner to control when a stage in a pipeline consumes resources.
As the owner of a resource, such as an environment, we can define approvals and checks that must be satisfied before a stage consuming that resource starts. Currently, manual approval checks are supported by environments.
We can control who can create, view, use, and manage the environments with user permissions. There are four roles — Creator (scope: all environments), Reader, User, and Administrator. In the specific environment’s user permissions panel, we can set the permissions that are inherited and we can override the roles for each environment.
- Navigate to the specific Environment that you would like to authorize.
- Click on the overflow menu button located at the top-right part of the page next to “Add resource” and choose Security to view the settings.
- In the User permissions blade, click on +Add to add a user or group and select a suitable Role.
Azure DevOps Pipeline | How To Use
Pipeline permissions can be used to authorize all or selected pipelines for deployment to the environment.
- To remove Open access on the environment or resource, click the Restrict permission in Pipeline permissions.
- To allow specific pipelines to deploy to an environment or a specific resource, click + and choose from the list of pipelines.
This is the basic YAML CICD pipeline without any environment resources such as VM’s or Kubernetes pods. But that said, we can also do the same way for the other resources as well.
- [AZ-400] Azure DevOps Certification Path
- [AZ-400] Roles And Responsibilities As An Azure DevOps Engineer
- [AZ-400] Microsoft Azure DevOps Certification Exam: Everything You Need To Know
- [AZ-400] Microsoft Azure DevOps Training: Step By Step Activity Guides/Hands-On Lab Exercise
- [AZ-400] Azure DevOps Services for Beginners
- [AZ-400] Designing and Implementing Microsoft DevOps Solutions [Official Page]
Next Task For You
Begin your journey towards becoming a Microsoft [AZ-400] Certified Azure DevOps Engineer and earning a lot more in 2020 by joining our FREE Masterclass.