-
Azure-DevOps
Data extraction and Power BI report that generate management informations about your Azure DevOps organization. Using Azure DevOps CLI and Azure DevOps REST API, PowerShell scripts extract data from Azure DevOps, store this information in an Azure SQL Database and shows them in a Power BI report.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
<# References1. https://github.com/vinijmoura/Azure-DevOps/blob/master/PowerShell/ListEnvironmentsDeploys/ListEnvironmentsDeploys.ps1#> $PAT = "PAT\_TOKEN"$Organization = "ORGANIZATION\_NAME"$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + \[Convert\]::ToBase64String(\[Text.Encoding\]::ASCII.GetBytes(":$($PAT)")) }$UriOrganization = "https://dev.azure.com/$($Organization)/"$ProjectID = "PROJECT\_NAME"$ReportFlag = 0MSTEAM\_WEBHOOK=""#### # Get Build Definitions$uriBuildDefinitions = $UriOrganization + "$ProjectID/\_apis/build/definitions?api-version=7.1-preview.7"$BuildDefintionsResult = Invoke-RestMethod -Uri $uriBuildDefinitions -Method get -Headers $AzureDevOpsAuthenicationHeader # Iterate through Build Definitions and get the latest build instance against the build definition ID Foreach ($builDef in $BuildDefintionsResult.value) { # https://learn.microsoft.com/en-us/rest/api/azure/devops/build/latest/get?view=azure-devops-rest-7.1 $uriLatestBuild = $UriOrganization + "$($ProjectID)/\_apis/build/latest/$($builDef.id)?branchName=master&api-version=7.0-preview.1" Try { $URLmaker = $UriOrganization + "$ProjectID" $LatestBuildResult = Invoke-RestMethod -Uri $uriLatestBuild -Method get -Headers $AzureDevOpsAuthenicationHeader # Get the details about the environments $uriEnvironments = "$($URLmaker)/\_apis/distributedtask/environments?api-version=7.1-preview.1" $EnvironmentsResult = Invoke-RestMethod -Uri $uriEnvironments -Method get -Headers $AzureDevOpsAuthenicationHeader Foreach ($environment in $EnvironmentsResult.value) { # Pull the details of build instance that deployed to production. if ($environment.name -eq "Production") { $uriEnvironmentDeployment = "$($URLmaker)/\_apis/distributedtask/environments/$($environment.id)/environmentdeploymentrecords?top=1&api-version=7.1-preview.1" $EnvironmentDeploymentResult = Invoke-RestMethod -Uri $uriEnvironmentDeployment -Method get -Headers $AzureDevOpsAuthenicationHeader # Checks if there a record exists and also if the stage is production if (($EnvironmentDeploymentResult.value.Count -gt 0) -and ($EnvironmentDeploymentResult.value\[0\].stageName -eq "Packer\_Build")) { $GetTimeline = $URLmaker + "/\_apis/build/builds/$($LatestBuildResult.id)/timeline?api-version=7.1-preview.2" $GetTimelineResult = Invoke-RestMethod -Uri $GetTimeline -Method get -Headers $AzureDevOpsAuthenicationHeader $FilterRecords = $GetTimelineResult.records if ($FilterRecords.Count -gt 0) { foreach ($record in $FilterRecords) { if ($record.type -eq "Stage" -and $record.name -eq 'Packer\_Build' -and $record.result -eq 'succeeded' ) { if ($((get-date ($LatestBuildResult.finishTime)).ToString("MM/dd/yyyy")) -eq $((Get-Date).ToString("MM/dd/yyyy"))) { $proddeploystarttime = $(Get-Date $record.startTime).ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss") $proddeployfinishtime = $(Get-Date $record.finishTime).ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss") $LatestBuildResult | Select-Object @{n = "Pipeline"; e = { $\_.definition.name } }, @{n = "Requestor"; e = { $\_.requestedFor.displayName } }, @{n = "StartTime"; e = { $($proddeploystarttime) } }, @{n = "FinishTime"; e = { $($proddeployfinishtime) } }, @{n = "Build#"; e = { $\_.buildNumber } }, @{n = "Status"; e = { $\_.result } }, @{n = "Project"; e = { $\_.project.name } }, @{n = "URL"; e = { "$URLmaker/\_build/results?buildid=" + $\_.id } } | Export-Csv -Path ./daily\_deployment\_report.csv -NoTypeInformation -Append -Encoding UTF8 $ReportFlag = 1 } } } } } } } } Catch { if ($\_.ErrorDetails.Message) { Write-Host $\_.ErrorDetails.Message } else { Write-Host $\_ } }