The following steps outline a method that I use to automate the retrieval of Azure Data Factory names along with their resource groups, and subsequently, the retrieval of Integration Runtimes and their statuses, specifically their versions. This is accomplished using two PowerShell scripts executed in Azure Cloud Shell.
Step 1: Export Data Factories and Resource Groups to CSV
Retrieve all Data Factories along with their corresponding Resource Groups and export the information to a CSV file.
Script:
# Login to Azure account if not already logged in (Cloud Shell automatically logs you in)
# Connect-AzAccount
# Get all resource groups
$resourceGroups = Get-AzResourceGroup
# Initialize an array to store the results
$dataFactoriesList = @()
# Iterate through each resource group
foreach ($rg in $resourceGroups) {
$rgName = $rg.ResourceGroupName
Write-Output "Processing Resource Group: $rgName"
try {
$dataFactories = Get-AzDataFactoryV2 -ResourceGroupName $rgName
if ($dataFactories -ne $null) {
Write-Output "Data Factories retrieved for Resource Group: $rgName - Count: $($dataFactories.Count)"
}
} catch {
Write-Output "Error retrieving Data Factories for Resource Group: $rgName. Error: $_"
continue
}
# Check if there are any data factories
if ($dataFactories -eq $null -or $dataFactories.Count -eq 0) {
Write-Output "No Data Factories found in Resource Group: $rgName"
continue
}
# Iterate through each data factory
foreach ($adf in $dataFactories) {
Write-Output " Data Factory Name: $($adf.DataFactoryName)"
$dataFactoriesList += [pscustomobject]@{
ResourceGroupName = $rgName
DataFactoryName = $adf.DataFactoryName
}
}
}
# Check the contents of $dataFactoriesList before exporting to CSV
Write-Output "Contents of dataFactoriesList:"
$dataFactoriesList | Format-Table -AutoSize
# Export the data factories list to a CSV file
$dataFactoriesList | Export-Csv -Path "$HOME/DataFactoriesList.csv" -NoTypeInformation
Write-Output "Data Factories list exported to $HOME/DataFactoriesList.csv"
Outcome:
This script produces a CSV file (DataFactoriesList.csv) containing the names of all Data Factories and their corresponding Resource Groups.
Step 2: Use CSV to Find Integration Runtimes and Their Statuses
Uses the CSV file from Step 1 to find Integration Runtimes for each Data Factory, retrieve their statuses, and specifically extract their versions.
Script:
# Import the CSV file
$dataFactoriesList = Import-Csv -Path "$HOME/DataFactoriesList.csv"
# Initialize an array to store the results
$integrationRuntimes = @()
# Iterate through each data factory in the CSV file
foreach ($entry in $dataFactoriesList) {
$rgName = $entry.ResourceGroupName
$adfName = $entry.DataFactoryName
Write-Output "Processing Data Factory: $adfName in Resource Group: $rgName"
try {
$integrationRuntimesInADF = Get-AzDataFactoryV2IntegrationRuntime -ResourceGroupName $rgName -DataFactoryName $adfName
} catch {
Write-Output "Error retrieving Integration Runtimes for Data Factory: $adfName in Resource Group: $rgName. Error: $_"
continue
}
# Check if there are any integration runtimes
if ($integrationRuntimesInADF -eq $null -or $integrationRuntimesInADF.Count -eq 0) {
Write-Output " No Integration Runtimes found in Data Factory: $adfName"
continue
}
# Iterate through each integration runtime
foreach ($ir in $integrationRuntimesInADF) {
$irName = $ir.Name
Write-Output " Processing Integration Runtime: $irName"
try {
$irStatus = Get-AzDataFactoryV2IntegrationRuntime -ResourceGroupName $rgName -DataFactoryName $adfName -Name $irName -Status
Write-Output " Status retrieved for Integration Runtime: $irName"
# Extract the version information from the status
$version = $irStatus.Version
} catch {
Write-Output "Error retrieving status for Integration Runtime: $irName in Data Factory: $adfName. Error: $_"
continue
}
$integrationRuntimes += [pscustomobject]@{
ResourceGroupName = $rgName
DataFactoryName = $adfName
IntegrationRuntimeName = $irName
Version = $version
}
}
}
# Output the results
if ($integrationRuntimes.Count -gt 0) {
$integrationRuntimes | Format-Table -AutoSize
# Optionally, you can export the results to a CSV file
$integrationRuntimes | Export-Csv -Path "$HOME/IntegrationRuntimesStatus.csv" -NoTypeInformation
Write-Output "Integration Runtimes status exported to $HOME/IntegrationRuntimesStatus.csv"
} else {
Write-Output "No Integration Runtimes found."
Outcome:
This script produces a CSV file (IntegrationRuntimesStatus.csv) containing the names of all Integration Runtimes, their respective Data Factories, Resource Groups, and their versions.
Summary:
These two PowerShell scripts automate the process of retrieving and exporting information about Azure Data Factories and their Integration Runtimes. The first script collects Data Factory names and their Resource Groups, while the second script uses this information to gather and export the statuses of Integration Runtimes, focusing on their versions. This method is useful for regularly monitoring and updating Integration Runtimes across multiple Data Factories and Resource Groups in an Azure environment.
This should be an available option in the Azure portal instead of admins trying to go to each ADF and find the versions of self-hosted IRs
Hooman Haghighat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.