skip to Main Content

In Azure Portal I have several "Function apps" and "App Services" that have Environment variables. Environment variables can have "App Settings" and "Connections strings".

I like to list "Environment Variables", for all services, by Name and Value.
My goal is to check for any wrong settings so I like all "Environment Variables" in a long list.

How can I do this from Azure Cloud Shell?
Thanks,

2

Answers


  1. You can use the following Azure CLI commands to list configuration settings of App Services and Function Apps.

    App Services:

    Function Apps:

    If you need to filter variables by type (App Settings, Azure SQL Database connection strings, custom connection strings, etc) take a look into the variable prefixes.

    Login or Signup to reply.
  2. To list all Environment variables from all App Services and Function Apps, you can make use of below sample PowerShell script:

    Connect-AzAccount
    
    $rGs = Get-AzResourceGroup
    $allSettings = @()
    
    foreach ($rg in $rGs) {
        $webApps = Get-AzWebApp -ResourceGroupName $rg.ResourceGroupName
    
        foreach ($webApp in $webApps) {
            $appSettings = (Get-AzWebApp -ResourceGroupName $rg.ResourceGroupName -Name $webApp.Name).SiteConfig.AppSettings
            foreach ($setting in $appSettings) {
                $allSettings += [pscustomobject]@{
                    ServiceName     = $webApp.Name
                    ResourceGroup   = $rg.ResourceGroupName
                    SettingName     = $setting.Name
                    SettingValue    = $setting.Value
                    SettingType     = "AppSetting"
                }
            }
    
            $connectionStrings = (Get-AzWebApp -ResourceGroupName $rg.ResourceGroupName -Name $webApp.Name).SiteConfig.ConnectionStrings
            foreach ($conn in $connectionStrings) {
                $allSettings += [pscustomobject]@{
                    ServiceName     = $webApp.Name
                    ResourceGroup   = $rg.ResourceGroupName
                    SettingName     = $conn.Name
                    SettingValue    = $conn.ConnectionString
                    SettingType     = "ConnectionString"
                }
            }
        }
    }
    
    $allSettings | Export-Csv -Path "$HOME/AllEnvironmentVariables.csv" -NoTypeInformation #exported to csv file
    $allSettings # print values to terminal
    

    Response:

    enter image description here

    AllEnvironmentVariables.csv:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search