01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az account list
--query '[*].id'
02 The command output should return the requested subscription identifiers (IDs):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
"abcdabcd-1234-abcd-1234-abcdabcdabcd",
"abcd1234-abcd-1234-abcd-abcd1234abcd"
]
03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to examine as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az account set
--subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
04 Run aks list command (Windows/macOS/Linux) with custom query filters to list the name and the associated resource group for each Azure Kubernetes Service (AKS) cluster available in the selected Azure subscription:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az aks list
--output table
--query '[*].{name:name, resourceGroup:resourceGroup}'
05 The command output should return the requested AKS cluster names:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
Name ResourceGroup
---------------------- ------------------------------
cc-data-mining-cluster cloud-shell-storage-westeurope
cc-project5-cluster cloud-shell-storage-westeurope
06 Run aks show command (Windows/macOS/Linux) with the name of the AKS cluster that you want to examine (and the associated resource group) as identifier parameters, to describe the ID of the service principal associated with the selected AKS cluster:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az aks show
--name cc-data-mining-cluster
--resource-group cloud-shell-storage-westeurope
--query 'servicePrincipalProfile.clientId'
07 The command output should return the requested service principal ID:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
"abcd1234-abcd-1234-abcd-abcd1234abcd"
08 Run ad app credential list command (Windows/macOS/Linux) with custom query filters to describe the creation date of the associated service principal:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
az ad app credential list
--id "abcd1234-abcd-1234-abcd-abcd1234abcd"
--query "[].startDateTime"
09 The command output should return the service principal creation date:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
[
"2024-05-12T06:29:02Z"
]
Check the timestamp returned by the
ad app credential list command output to determine when the selected service principal and its credentials were created. If more than 90 days have passed since the resource was created, the credentials for the selected AKS cluster are not being rotated regularly.
10 Repeat steps no. 6 - 9 for each AKS cluster provisioned within the selected Azure subscription.
11 Repeat steps no. 3 – 10 for each subscription created in your Microsoft Azure cloud account.