List App Service Runtimes

A common ask from customers is how to list out the stack that is configured for an app service. The script below uses Azure PowerShell to enumerate the resources that fall under Microsoft.Web including Web Apps, Functions Apps, and Logic App Standard for both the Linux and Windows offerings. This has not been tested with Windows Container App so slight modifications may be required.


$table = New-Object System.Data.DataTable


$appListArray = @()

$resourceGroups = Get-AzResourceGroup
foreach ($resourceGroup in $resourceGroups) {
	$webApps = Get-AzWebApp -ResourceGroupName $resourceGroup.ResourceGroupName
    foreach($webapp in $webApps){
        $appName = $webapp.Name
        $group = $resourceGroup.ResourceId

        #URIs to retrieve Stack and Version using rest api calls
        $stackUri = "$group/providers/Microsoft.Web/sites/$appName/config/metadata/list?api-version=2020-10-01"
        $stackVersionUri = "$group/providers/Microsoft.Web/sites/$appName/config?api-version=2020-10-01"
        $appTypeUri = "$group/providers/Microsoft.Web/sites/$appName`?api-version=2023-01-01"

        #Calling Config properties
        $stackProperties = Invoke-AzRestMethod -Path $stackUri -Method POST
        $stackVersionProperties = Invoke-AzRestMethod -Path $stackVersionUri -Method GET
        $appType = Invoke-AzRestMethod -Path $appTypeUri -Method GET

        #convert response to JSON
        $stackJson = $stackProperties.Content | ConvertFrom-Json
        $stackVersionJson = $stackVersionProperties.Content | ConvertFrom-Json
        $appTypeJson = $appType.Content | ConvertFrom-Json

            #$image = $stackVersionJson.value[0].properties.linuxFxVersion
            $runtime = $stackVersionJson.value[0].properties.linuxFxVersion.split("|")[0]
            $version = $stackVersionJson.value[0].properties.linuxFxVersion.split("|")[1]
            $os = "Linux"
            $type = $appTypeJson.kind
            $runtime = $
            switch($runtime = $
                python {$version = $stackVersionJson.value[0].properties.pythonVersion}
                node {$version = $stackVersionJson.value[0].properties.nodeVersion}
                php {$version = $stackVersionJson.value[0].properties.phpVersion}
                java {$version = $stackVersionJson.value[0].properties.javaVersion}
                dotnet {$version = $stackVersionJson.value[0].properties.netFrameworkVersion}
                dotnetcore {$version = $stackVersionJson.value[0].properties.netFrameworkVersion}
                default {$version = "No stack version found. This could be a LogicApp standard or function app edge case. Please manually check"}
            $os = "Windows"
            $type = $appTypeJson.kind

        #create the array for CSV
        $obj = [PSCustomObject]@{
            AppName = "$appName"
            ResourceGroup = "$group"
            OS = "$os"
            Runtime = "$runtime"
            Version = "$version"
            AppType = "$type"

        $appListArray += $obj

        #append to the table 
#create the CSV
$appListArray | Export-Csv -Path C:\temp\output.csv -NoTypeInformation

#create a JSON object
$json = ConvertTo-Json $appListArray

Example output:
Table View
CSV View