Last active
August 12, 2020 11:36
-
-
Save bjorkstromm/9ce31820b297a1cd163364f1df4b704c to your computer and use it in GitHub Desktop.
List Application Insights configurations for Web Apps and Function Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$webApps = ConvertFrom-Json([string](& az webapp list --query "[*].{name: name, resourceGroup: resourceGroup}" -o json)) | |
$webApps | ForEach-Object { | |
Write-Host $_.Name | |
$settings = ConvertFrom-Json([string](& az webapp config appsettings list -n $_.name -g $_.resourceGroup --query "{APPINSIGHTS_INSTRUMENTATIONKEY: [?name=='APPINSIGHTS_INSTRUMENTATIONKEY'].value | [0], APPLICATIONINSIGHTS_CONNECTION_STRING: [?name=='APPLICATIONINSIGHTS_CONNECTION_STRING'].value | [0]}")) | |
$_ | Add-Member -NotePropertyName APPINSIGHTS_INSTRUMENTATIONKEY -NotePropertyValue $settings.APPINSIGHTS_INSTRUMENTATIONKEY | |
$_ | Add-Member -NotePropertyName APPLICATIONINSIGHTS_CONNECTION_STRING -NotePropertyValue $settings.APPLICATIONINSIGHTS_CONNECTION_STRING | |
} | |
$funcApps = ConvertFrom-Json([string](& az functionapp list --query "[*].{name: name, resourceGroup: resourceGroup}" -o json)) | |
$funcApps | ForEach-Object { | |
Write-Host $_.Name | |
$settings = ConvertFrom-Json([string](& az functionapp config appsettings list -n $_.name -g $_.resourceGroup --query "{APPINSIGHTS_INSTRUMENTATIONKEY: [?name=='APPINSIGHTS_INSTRUMENTATIONKEY'].value | [0], APPLICATIONINSIGHTS_CONNECTION_STRING: [?name=='APPLICATIONINSIGHTS_CONNECTION_STRING'].value | [0]}")) | |
$_ | Add-Member -NotePropertyName APPINSIGHTS_INSTRUMENTATIONKEY -NotePropertyValue $settings.APPINSIGHTS_INSTRUMENTATIONKEY | |
$_ | Add-Member -NotePropertyName APPLICATIONINSIGHTS_CONNECTION_STRING -NotePropertyValue $settings.APPLICATIONINSIGHTS_CONNECTION_STRING | |
} | |
$webApps + $funcApps | ConvertTo-Csv -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment