Skip to content

Instantly share code, notes, and snippets.

@jankurianski
Created August 7, 2023 05:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jankurianski/6751c36fa07c2c988532a90da391c3b5 to your computer and use it in GitHub Desktop.
Save jankurianski/6751c36fa07c2c988532a90da391c3b5 to your computer and use it in GitHub Desktop.
Azure: list all custom domains of all endpoints of all CDN profiles of all subscriptions
#!/usr/bin/bash
set -euo pipefail
# List all custom domains of all endpoints of all CDN profiles of all subscriptions
echo "CUSTOM_DOMAIN,ENDPOINT_NAME,CDN_NAME,RESOURCE_GROUP,SUBSCRIPTION"
SUBSCRIPTIONS=$(az account list --query "[].{id:id}" -o tsv)
echo "$SUBSCRIPTIONS" | while read -r SUBSCRIPTION
do
az account set --subscription $SUBSCRIPTION
CDN_NAME_AND_RESOURCE_GROUP=$(az cdn profile list --query "[].{name:name,resourceGroup:resourceGroup}" -o tsv)
echo "$CDN_NAME_AND_RESOURCE_GROUP" | while read -r CDN
do
if [ -n "$CDN" ]
then
CDN_NAME=$(echo "$CDN" | cut -f1)
RESOURCE_GROUP=$(echo "$CDN" | cut -f2)
ENDPOINT_NAMES=$(az cdn endpoint list --profile-name $CDN_NAME --resource-group $RESOURCE_GROUP --query "[].name" -o tsv)
echo "$ENDPOINT_NAMES" | while read -r ENDPOINT_NAME
do
if [ -n "$ENDPOINT_NAME" ]
then
CUSTOM_DOMAINS=$(az cdn custom-domain list --endpoint-name $ENDPOINT_NAME --profile-name $CDN_NAME --resource-group $RESOURCE_GROUP --query "[].hostName" -o tsv)
echo "$CUSTOM_DOMAINS" | while read -r CUSTOM_DOMAIN
do
if [ -n "$CUSTOM_DOMAIN" ]
then
echo "$CUSTOM_DOMAIN,$ENDPOINT_NAME,$CDN_NAME,$RESOURCE_GROUP,$SUBSCRIPTION"
fi
done
fi
done
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment