Check Function App Stack
This script is for retrieving all of the function app stacks in your Azure Subscriptions you have access to.
#!/bin/bash
# Log in to Azure (if not already logged in)
# az login
# Get the list of subscriptions
subscriptions=$(az account list --query "[].id" -o tsv)
# Print the header of the CSV.
echo "subscroptionId, name, resourceGroup, stack"
# Iterate through each subscription
while IFS= read -r subscriptionId; do
# Set the current subscription
az account set --subscription "$subscriptionId"
# List all Function Apps in the current subscription
function_apps=$(az functionapp list --query "[].{name:name, resourceGroup:resourceGroup}" -o tsv)
# Iterate through each Function App
while IFS=$'\t' read -r name resourceGroup; do
# Get the configuration of the Function App
config=$(az functionapp config show --name "$name" --resource-group "$resourceGroup" -o json)
# Extract the stack and stack version
linuxFxVersion=$(echo "$config" | grep -oP '(?<="linuxFxVersion": ")[^"]*')
windowsFxVersion=$(echo "$config" | grep -oP '(?<="windowsFxVersion": ")[^"]*')
# Determine the stack and version
if [ -n "$linuxFxVersion" ]; then
stack="$linuxFxVersion"
elif [ -n "$windowsFxVersion" ]; then
stack="$windowsFxVersion"
else
stack="Unknown"
fi
# Print the Function App details
echo $subscriptionId, $name, $resourceGroup, $stack
done <<< "$function_apps"
done <<< "$subscriptions"