AKS `kubectl get pods` returns `Error from server (Forbidden): pods is forbidden: User "[email protected]" cannot list resource "pods" in API group "" in the namespace "shop": User does not have access to the resource in Azure. Update role assignment to allow access.`
BeginnerTroubleshootingIdentity and Authorization Errors
Answer
Likely causes → Azure RBAC for Kubernetes is enabled and the user has no AKS RBAC role at the cluster or namespace scope.
Diagnose →
az role assignment list --assignee [email protected] --scope $(az aks show -g rg -n aks --query id -o tsv) --include-inherited -o table
Fix →
az role assignment create --assignee [email protected] --role "Azure Kubernetes Service RBAC Reader" \
--scope "$(az aks show -g rg -n aks --query id -o tsv)/namespaces/shop"
Prevent → Grant namespace roles to groups as part of namespace onboarding.
More on Identity and Authorization Errors
`(AuthorizationFailed) The client '[email protected]' with object id '1111...' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/.../resourcegroups/rg-shop-dev' or the scope is invalid.`Beginner`AADSTS70021: No matching federated identity record found for presented assertion. Assertion Issuer: 'https://token.actions.githubusercontent.com'. Assertion Subject: 'repo:devopsshack/shop:ref:refs/heads/feature/login'.`Beginner`AADSTS7000222: The provided client secret keys for app '2222...' are expired.` Pipelines failed overnight.Beginner`AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '797f4846-ba00-4fd7-ba43-dac1f8f63013'.` in a nightly script.Intermediate`Code: Forbidden. Message: Caller is not authorized to perform action on resource. Action: 'Microsoft.KeyVault/vaults/secrets/getSecret/action' ... Inner error: {"code":"ForbiddenByRbac"}`Beginner`The user, group or application 'appid=...;oid=...' does not have secrets get permission on key vault 'kv-legacy;location=centralindia'.`Beginner