How to: Environments, Approvals, and Checks Mapping on Azure DevOps

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on Azure DevOps;
  • $Organization = Organization URL to list all Environments, Approvals, and Checks on Azure DevOps organization;
  • $Connstr = connection string to Azure SQL Database that stores the report information. To create this report, it’s necessary to create previously a Azure SQL Server and Database and run a script below:
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($PAT)")) }$UriOrganization = "https://dev.azure.com/$($Organization)/" $uriProject = $UriOrganization + "_apis/projects?`$top=500"$ProjectsResult = Invoke-RestMethod -Uri $uriProject -Method get -Headers $AzureDevOpsAuthenicationHeaderForeach ($project in $ProjectsResult.value)
{
Write-Host $project.name
}
$uriEnvironments = $UriOrganization + "$($project.id)/_apis/distributedtask/environments?api-version=6.1-preview.1"    $EnvironmentsResult = Invoke-RestMethod -Uri $uriEnvironments -Method get -Headers $AzureDevOpsAuthenicationHeader    Foreach ($environment in $EnvironmentsResult.value)    
{
Write-Host $environment.name
}
$body = @(
@{
type="queue"
id="1"
name="Default"
},
@{
type="environment"
id="$($environment.id)"
name="$($environment.name)"
}
) | ConvertTo-Json
$uriEnvironmentChecks = $UriOrganization + "$($project.id)/_apis/pipelines/checks/queryconfigurations?`$expand=settings&api-version=6.1-preview.1"$EnvironmentChecksResult = Invoke-RestMethod -Uri $uriEnvironmentChecks -Method Post -Body $body -Headers $AzureDevOpsAuthenicationHeader -ContentType application/json Foreach ($envcheck in $EnvironmentChecksResult.value)
{
Write-Host $envcheck.type.name
}
  • Team Project (1) = Filter report using Team Project field;
  • Environment (2) = Filter report using Environment field;
  • Approvals and Checks (3) = Filter report using Approvals and Checks types.
  • Report Information (4) = List all information about Environments, Approvals, and Checks. If the respective approval and check appear in this mapping, the same will be marked (green ticks on a grid).

--

--

--

Tech Solution Architect Manager na Accenture

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Java Interview Questions for Beginners — 5

Learning to Code

Bit Manipulation: Interview Questions to Practice

Android Development 101 — (Positivity Dose) : Tutorial 3 : Activity to Fragment

5 reasons why testing is incomplete without cross-browser tests?

Fun with Sitecore and face recognition (like in Facebook)

PHP restful API with sim-rest ( only 10 KB )

What is an Algorithm?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinicius Moura

Vinicius Moura

Tech Solution Architect Manager na Accenture

More from Medium

How to: Release Badges Dashboard on Azure DevOps

Automate Azure Events with an Event Grid

How to set up the Azure Front door for your web application?

Azure Cosmos DB — Using PowerShell for bulk deletes and inserts