When attempting to delete a service principal, should the query for the 'displayName' be the name of the AKS cluster? As stated in the doc, that search didn't work for me (eventually errored out). However, when I searched in the Azure Portal, I could find it. The service principal display name was not exactly the same as the name of the AKS cluster. The display name started with the AKS cluster name, but also had "SP" and the create date appended.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Thanks for the feedback! We are currently investigating and will update you shortly.
@mcollier did you manually create a service principal or allow Azure to do it for you?
If you allow Azure to automatically create one for you such as using the following:
az aks create --name myAKSCluster --resource-group myResourceGroup --generate-ssh-keys
A service principal will be created and the name of the cluster will be used

But if you manually create a SP the name would be different
az ad sp create-for-rbac --skip-assignment
The command to get a list of the service principals seems to be having issues as I ran it by itself and it still stalls. So that might be something unrelated.

@iainfoulds maybe we should mention how the service principal names work if you manually create them?
@mcollier any update on this?
The SP was created automatically for me when I created the cluster via the Azure Portal.
Yes, I noticed that problem with the 'az ad app list' command as well. It eventually exited it an error, and I was able to quickly find and delete the SP via the Azure AD blades in the Azure Portal.
Thanks @mcollier
I will assign to the author to review further
@iainfoulds can you take a look?
Looks like az ad sp delete --id $(az aks show -g myResourceGroup -n myAKSCluster --query servicePrincipalProfile.clientId -o tsv) would be a cleaner way to do this since there are naming differences between manually creating a service principal or letting the Azure CLI or then Azure portal create one. I'll update the doc accordingly.
Most helpful comment
Looks like
az ad sp delete --id $(az aks show -g myResourceGroup -n myAKSCluster --query servicePrincipalProfile.clientId -o tsv)would be a cleaner way to do this since there are naming differences between manually creating a service principal or letting the Azure CLI or then Azure portal create one. I'll update the doc accordingly.