Author : MD TAREQ HASSAN | Updated : 2022/01/09
What is environment in Azure DevOps
- An environment is a collection of resources that you can target with deployments from a pipeline
- Environments represent a group of resources for a Pipeline. The resources themselves are the actual deployment targets to which artifacts will be deployed
- Evironment resource example: AKS Resource (AKS itself is the deployment target)
- Environment belongs to the release process
Create AKS environment
- Environemnts > Create new environment
- Fillup Name and Description > Next
- Provider: Azure Kubernetes Service
- Select target subscription
- Select cluster
- Namespace
- New
- Name: ‘devops-demo’
- Validate and create
Use Environment as Target in Deployment Jobs
Kubernetes
jobs:
# ... ... ...
- deployment: deployToAKS
displayName: Deploy to AKS
dependsOn: buildAndPushDockerImageJob
environment: 'AKSDemoEnvironment.devops-demo'
strategy:
runOnce:
deploy:
steps:
- script: echo "Hello world"
VM / On-premise server
jobs:
# ... ... ...
- deployment: VMDeploy
displayName: Deploy to VM
environment:
name: ContosoDeploy
resourceType: VirtualMachine
tags: windows # only deploy to virtual machines with this tag
strategy:
runOnce:
deploy:
steps:
- script: echo "Hello world"
Observability
- Environemnts > select target environment
- Resources: mapped K8s namespace
- Deployments: CD deployments
- Resources
- Select target namespace
- Workloads: same as AKS workloads for the namespace
- Services: same as AKS services for the namespace
- Workloads
- Select target replicaSet, will show details
- Select any pod, will show followings
- Overview
- Logs
- YAML
- Services
- Select target service, will show details
- Select any pod, will show followings
- Overview
- Logs
- YAML
- Select target namespace
- Deployments
- Select a run
- Will show
- Jobs
- Changes
- Workitems
Approval
- Environemnts > select target environment
- Vertical dots on top right > Approvals and checks
- Click “+” icon > Approvals
- Select user or group > Create
Security
- Environemnts > Select target environment
- Vertical dots on top right > Security