HoussemDellai / aks-keyvault

Access Azure Key Vault secrets, keys and certs from AKS Pods using Secret Store CSI provider and Pod Identity.
28 stars 55 forks source link

az identity show #3

Open cpatil7 opened 4 years ago

cpatil7 commented 4 years ago

Hey,

While following the instruction as per below https://github.com/HoussemDellai/aks-keyvault/blob/master/commands-identity.ps1

when trying to retrieve existing identity

If using AKS with Managed Identity, retrieve the existing Identity

If ($isAKSWithManagedIdentity -eq "true") { echo "Retrieving the existing Azure Identity..." $existingIdentity = az resource list -g $aks.nodeResourceGroup --query "[?contains(type, 'Microsoft.ManagedIdentity/userAssignedIdentities')]" | ConvertFrom-Json $identity = az identity show -n $existingIdentity.name -g $existingIdentity.resourceGroup | ConvertFrom-Json }

echo $existingIdentity, it will retrieve three entries as below

None None /subscriptions/xxxxxxxxxxxx/resourceGroups/MC_rg-demo01_aks-demo01_westeurope/providers/Microsoft.ManagedIdentity/userAssignedIdentities/aks-demo01-agentpool None None westeurope None aks-demo01-agentpool None None None MC_rg-demo01_aks-demo01_westeurope None Microsoft.ManagedIdentity/userAssignedIdentities

None None /subscriptions/xxxxxxxxx/resourceGroups/MC_rg-demo01_aks-demo01_westeurope/providers/Microsoft.ManagedIdentity/userAssignedIdentities/kubedashboard-aks-demo01 None None westeurope None kubedashboard-aks-demo01 None None None MC_rg-demo01_aks-demo01_westeurope None Microsoft.ManagedIdentity/userAssignedIdentities

None None /subscriptions/xxxxxxxxxxxxxx/resourceGroups/MC_rg-demo01_aks-demo01_westeurope/providers/Microsoft.ManagedIdentity/userAssignedIdentities/omsagent-aks-demo01 None None westeurope None omsagent-aks-demo01 None None None MC_rg-demo01_aks-demo01_westeurope None Microsoft.ManagedIdentity/userAssignedIdentities

Idenity will throw error as below

$identity = az identity show -n $existingIdentity.name -g $existingIdentity.resourceGroup | ConvertFrom-Json
az: error: unrecognized arguments: kubedashboard-aks-demo01 omsagent-aks-demo01 MC_rg-demo01_aks-demo01_westeurope MC_rg-demo01_aks-demo01_westeurope