This blog talks about technologies that are part of the Azure DevOps environments. 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 | Azure DevOps Pipeline
What Is Azure DevOps Environments?
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.
Also read: Everything you need to know on Azure SQL Database
How To Setup Azure DevOps Environment
- 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.
Also check: Azure DevOps Certification Path to know more about the certifications to be a Microsoft Certified DevOps Engineer.
Environments provide the following benefits
Without needing to purchase and/or maintain the underlying infrastructure, Azure enables you to design, launch, and manage apps more rapidly and easily. Azure’s integrated cloud resources are easily configurable to a company’s specific requirements while meeting all of your security and compliance requirements.
Azure, which is thought to be the second-largest IaaS and PaaS service provider globally, additionally has the benefit of being completely integrated with all Microsoft goods. Azure is a wonderful fit for people who already have a Microsoft infrastructure and your current programmes and apps. Azure is the go-to option for companies trying to expand and keep one step ahead of the competition since it is adaptable, economical, and technologically cutting edge.
Target an environment from a deployment job
A deployment task is a set of actions that must be carried out in order. As demonstrated in the following YAML sample, a deployment task can be used to target a complete environment (collection of resources).You can limit the deployment’s goal to a certain environment resource. Then, you can keep a deployment history log for a particular environment resource. The service connection information is automatically inherited by the deployment job’s steps from the resource it is targeting.
Target a specific resource within an environment from deployment job
You can limit the deployment’s goal to a certain environment resource. Then, you can keep a deployment history log for a particular environment resource. The service connection information is automatically inherited by the deployment job’s steps from the resource it is targeting.
Environment in run details
Utilize virtual machine (VM) resources to handle deployments using YAML pipelines across various machines. You can install agents on your own servers using VM resources for rolling deployments.
Environments are connected to via VM resources. Following the definition of an environment, VMs can be added to the deployment target list. Traceability from your virtual machine to your pipeline is made possible by the deployment history view in an environment.
Deployment history
You are able to see your deployment history with Azure Resource Manager. You may look up particular operations from previous deployments to see what resources were used. Any mistakes are recorded in this history.
A resource group’s deployment history is restricted to 800 deployments. Deployments are automatically removed from the history as you get close to the limit. See Automatic removals from deployment history for further details.
Through the Azure portal, PowerShell, Azure CLI, or REST API, you can examine information about a resource group deployment. Choose the resource group that you want to investigate. Go to Deployments and click the link. From the deployment history, pick a deployment.
See Troubleshoot common Azure deployment difficulties for assistance in fixing specific deployment errors.
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.
Also read: Our blog post on Microsoft Azure Management Tools Click here
Azure Pipelines Permissions | 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.
FAQ’s
Q.1 What Are the Features of Azure DevOps?
Ans. the Features of Azure DevOps are
- Dashboard Control.
- Improved Source Control.
- Plan and Track Your Work.
- Continuous Integration and Deployment (CI/CD)
- Support for Manual and Exploratory Testing.
- Integrated Collaboration Services.
- Azure Cloud-hosted Services.
Q.2 How do I set up a DevOps environment?
Establish the CI/CD tool in step 1. Picking a CI/CD tool should be the first step for businesses just starting to establish a DevOps pipeline.
Source a control environment in step two.
Build Server setup.
Create or install testing automation tools.
To production, deploy.
Q.3 What is the environment variable in DevOps?
Ans. You may easily insert important pieces of data into different stages of the pipeline by using variables. Variables are most frequently used to define a value that can subsequently be used in your pipeline. All variables are mutable and stored as strings. A variable’s value may vary from pipeline run to pipeline run or job to job.
The variable that is more locally scoped takes precedence when it is defined with the same name several times. Therefore, a variable specified at the stage level can be overridden by a variable established at the job level. A variable set at the pipeline root level will be overridden by a variable declared at the stage level. a parameter set at the root level of the pipeline
Q.4 How do you use variables in Azure Devops release pipeline?
Ans. In a release pipeline, the Variables tab is where you define and control these variables. Open the Scope drop-down list on the Pipeline Variables page and choose “Release” from the list. When you add a variable, its default setting is Release scope. Utilize stage variables to share values among all of the tasks inside a single stage.
An output variable is one kind of variable you could see in a pipeline. A particular class of pipeline variable produced by a task is known as an output variable. A variable is given a value by the deployment job, which subsequently makes it usable across a pipeline.
Related/References
-
- [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]
- Azure Pipelines vs Jenkins
- Azure Pipelines vs Jenkins
- Azure DevOps Interview Questions And Answers For Beginners, Intermediate, And Experienced
Next Task For You
Begin your journey toward Mastering Azure Cloud and landing high-paying jobs. Just click on the register now button on the below image to register for a Free Class on Mastering Azure Cloud: How to Build In-Demand Skills and Land High-Paying Jobs. This class will help you understand better, so you can choose the right career path and get a higher paying job.
Gary Melhaff says
Be great if you could provide context in how this fits into and enhances existing pipelines. I mean I’m running pipelines without any of this and wondering what I’m missing. Pipeline already automatically allocates a vm to run the deployment so not sure what the environment gives me there. Also the command to register the environment in Azure just gives an error so I’m guessing there is some kind of permissions you need? (I’m owner of RGs and contributor for the subscription). Note problem with most Azure stuff is it never seems to work when you try it on your own because there’s so many required pieces, especially permissions so great if you could include little more info. Plus the yaml file is too small to see what you actually added for the environment.
Shan says
Exactly, had the same question. What’s the purpose of the environment.
Talal says
Is this pipeline published on Github?
Robert Stuckey says
Thats Really Amazing Article
Surbhi Sharma says
Hello Robert, Glad you liked our post, stay tuned for more informative content.
Regards,
Surbhi
team k21
victor ucan says
hello, creating the environments for example dev, qa and prod is it the same to do it from azure devops than outside of azure devops? or what would be the best
Rahul Dangayach says
Hi Victor,
Creating environments for dev, qa, and prod is the same whether you do it from Azure DevOps or outside of Azure DevOps. However, there are some advantages to creating environments in Azure DevOps.
* **Azure DevOps provides a central place to manage all of your environments.** This makes it easy to track which environments are in use, who has access to each environment, and what resources are available in each environment.
* **Azure DevOps provides a number of features that make it easier to deploy and manage applications in different environments.** For example, you can use Azure DevOps to create and manage virtual machines, configure firewalls, and deploy applications to different environments.
* **Azure DevOps can be integrated with other tools that you use for development and deployment.** This makes it easy to automate the process of creating and managing environments.
Overall, I would recommend creating environments in Azure DevOps. This will give you a number of advantages that can help you to improve your development and deployment processes.
Here are the steps on how to create environments in Azure DevOps:
1. Sign in to your Azure DevOps organization.
2. Click on the project that you want to create the environment in.
3. In the left-hand menu, click on “Pipelines”.
4. Under “Environments”, click on “Create environment”.
5. Enter a name for the environment.
6. Select the type of environment that you want to create.
7. (Optional) Select the resources that you want to include in the environment.
8. Click on “Create”.
Once you have created an environment, you can use it to deploy your applications to different environments. You can also use Azure DevOps to manage the resources that are available in each environment.
Thanks and Regards
Rahul Dangayach
Team K21Academy