Forum Discussion
ved-leachim
Jan 30, 2024Brass Contributor
Identify classic Application Insights for migration to workspaces
Hello everyone,
As many of you may already be aware, the classic version of https://learn.microsoft.com/en-us/azure/azure-monitor/app/convert-classic-resource on February 29, 2024. To assist with this transition, I've written a PowerShell script that can identify these classic Application Insights resources on a per-subscription basis.
I believe this script could be beneficial to others.
# Connect-AzAccount
Set-AzContext -Subscription "SUBSCRIPTIONNAME" | Out-Null
$AppInsights = Get-AzApplicationInsights
$ClassicAppInsights = @()
ForEach($AppInsight in $AppInsights) {
# This try-catch is needed, since sometimes .IngestionMode seems to reference to nothing
# Object reference not set to an instance of an object.
try {
if ($null -eq $AppInsight.IngestionMode -or
$AppInsight.IngestionMode -eq "" -or
$AppInsight.IngestionMode -ne "LogAnalytics"){
$ClassicAppInsights += $AppInsight
}
} catch {
$ClassicAppInsights += $AppInsight
}
}
$ClassicAppInsights | ft
Kudos to https://www.isjw.uk/post/software/powershell-classic-azure-app-insights/ for providing the initial inspiration for this script. Although their approach didn't list all the affected Application Insights in my case, it served as an excellent starting point for my work.
No RepliesBe the first to reply