π
Fixing ErrorApplicationGatewayForbidden in AKS + Application Gateway
When running:
- Azure Kubernetes Service
- Azure Application Gateway
- Azure Application Gateway Ingress Controller
You may encounter this error inside AGIC logs:
ErrorApplicationGatewayForbidden
StatusCode=403
Microsoft.Network/applicationGateways/read
This tutorial explains:
- β Why this happens
- π How to diagnose it
- π How to fix it properly
- π How to prevent it next time
π The Error
From AGIC logs:
kubectl logs -n kube-system deploy/ingress-appgw-deployment
Youβll see something like:
Unexpected status code '403' while performing a GET on Application Gateway
AuthorizationFailed
And:
The client '<object-id>' does not have authorization to perform action
'Microsoft.Network/applicationGateways/read'
π§ Root Cause
AGIC runs using a managed identity.
That identity must have Azure RBAC permissions to:
- Read Application Gateway
- Modify listeners
- Modify backend pools
- Modify routing rules
If those permissions are missing β AGIC cannot configure App Gateway β 403 error.
This usually happens when:
- App Gateway was created manually
- Cross-resource-group setup
- Subscription policies restrict automatic role assignment
- Infrastructure created in separate steps
π How AGIC Actually Works (Important to Understand)
Flow:
Ingress YAML
β
AGIC watches cluster
β
Calls Azure API
β
Modifies Application Gateway config
AGIC is essentially a controller that:
- Talks to Azure ARM API
- Updates App Gateway dynamically
Without RBAC β it cannot call Azure API.
π Step 1 β Identify AGIC Managed Identity
Run:
az aks show \
--resource-group <RG> \
--name <AKS_NAME> \
--query addonProfiles.ingressApplicationGateway.identity.objectId \
-o tsv
Save the output:
AGIC_OBJECT_ID=<value>
That is the identity failing in the logs.
π Step 2 β Verify Missing Role
Check current assignments:
az role assignment list \
--assignee $AGIC_OBJECT_ID \
-o table
Youβll likely see:
- No Contributor on App Gateway
- No Reader on Resource Group
Thatβs the problem.
π Step 3 β Fix RBAC Properly
β 1. Assign Reader on Resource Group
az role assignment create \
--assignee $AGIC_OBJECT_ID \
--role Reader \
--scope /subscriptions/<SUB_ID>/resourceGroups/<RG>
Why?
AGIC reads resource group metadata.
β 2. Assign Contributor on Application Gateway
Get App Gateway ID:
APPGW_ID=$(az network application-gateway show \
--name <APPGW_NAME> \
--resource-group <RG> \
--query id -o tsv)
Assign Contributor:
az role assignment create \
--assignee $AGIC_OBJECT_ID \
--role Contributor \
--scope $APPGW_ID
Why Contributor?
AGIC must:
- Update listeners
- Update backend pools
- Update HTTP settings
- Update routing rules
Reader is not enough.
π Step 4 β Restart AGIC
kubectl rollout restart deployment ingress-appgw-deployment -n kube-system
Then check logs again:
kubectl logs -n kube-system deploy/ingress-appgw-deployment
The error should disappear.
You should now see:
Applied App Gateway configuration
π§ͺ Step 5 β Validate End-to-End
Test your endpoint:
https://<front-door-or-appgw-url>
Traffic should now:
Front Door (optional)
β
Application Gateway
β
AKS
No more retry loop.
π‘ Production Best Practice (Important)
Instead of giving full Contributor on the entire resource group:
π Use Least Privilege
Scope Contributor only to:
/resourceGroups/<RG>/providers/Microsoft.Network/applicationGateways/<APPGW_NAME>
Even better:
Create a custom RBAC role limited to:
Microsoft.Network/applicationGateways/*
For finance / banking / regulated environments.
π¨ Common Variations of This Problem
| Symptom | Cause |
|---|---|
| AGIC keeps retrying | Missing RBAC |
| 403 only on update | Missing Contributor |
| Works initially, fails later | Identity changed |
| Cross-subscription setup | Wrong scope |
π§ Prevention Checklist (Use This Next Time)
When creating AKS with AGIC:
az aks create \
--enable-addons ingress-appgw \
--appgw-id <ID>
Immediately after:
- Get AGIC identity
- Assign:
- Reader on RG
- Contributor on App Gateway
- Verify with
az role assignment list
- Verify with
Make this part of your infrastructure checklist.
π¦ Enterprise Architecture Insight
In large organizations:
- Network team owns Application Gateway
- Platform team owns AKS
- RBAC must be explicitly granted
This error is extremely common in enterprise environments.
Understanding it makes you significantly stronger in Azure architecture.
π― Final Summary
Problem
AGIC 403 AuthorizationFailed
Cause
Managed identity missing RBAC permissions
Fix
Assign:
- Reader β Resource Group
- Contributor β Application Gateway
Result
AGIC can successfully reconcile Ingress β App Gateway config
Top comments (0)