AKS and Microsoft Entra ID
Demo source and Kubernetes manifest
The homepage is public. A visitor selects Sign in with Microsoft Entra ID to open the protected account page. The account page displays the name, sign-in name, identity provider, user object ID and tenant ID when Entra supplies them. The app keeps raw tokens out of the page and uses an HTTP-only session cookie.
The AKS kubelet identity pulls the private application image from Azure Container Registry. The visitor signs in through a separate, single-tenant Entra app registration. Caddy terminates HTTPS on the public AKS Service and proxies to the Node app on port 8080.
Select a screenshot to open the original-sized crop. Sensitive values are covered in the published copies.
1. Create the AKS cluster in the Azure portal
Open Kubernetes services > Create > Kubernetes cluster. Choose the subscription and create a dedicated resource group. In Basics, select Dev/Test, choose the region, name the cluster and verify Free pricing tier.
In Node pools, edit the system pool. Select a supported Linux VM with at least four vCPUs. The rehearsal used two fixed Standard_D4as_v5 nodes and no extra node pool. Select Manual and set Node count to 2.
Review networking. The AKS cluster uses the Standard Azure Load Balancer. The application manifest adds a public listener with an Azure DNS label. In Integrations, select an existing private ACR in your tenant if you have one. This walkthrough reused the Container Apps demo’s Basic registry and created a separate image repository in it.
In Monitoring, leave optional Container Logs, Prometheus and Grafana disabled for this rehearsal. Review the configuration and select Create.
2. Register the website in Microsoft Entra
- Pick a unique DNS label. Use the public name
<dns-label>.<azure-region>.cloudapp.azure.comin this walkthrough. Under App registrations > New registration, choose Single tenant only and add a Web redirect URI athttps://<hostname>/auth/redirect. - After registration, also add
https://<hostname>/as a Web redirect URI so Entra can return to the public homepage after sign-out. - From the app registration overview, open the link under Managed application in local directory. Under Properties, set Assignment required? to Yes and save. Under Users and groups > Add user/group, select the presenter and choose Assign.
- Under Certificates & secrets, create an expiring secret for the confidential web client. Use it to provision the Kubernetes Secret. Keep the value out of screenshots, manifests and Git.
3. Build and deploy the application
Connect to the cluster through Overview > Connect. Use the available Kubernetes authentication mode and a principal permitted to create workloads and Secrets in the demo namespace. The portal shows cluster settings and workload status. Use Cloud Shell or a signed-in local terminal to build the image, create the Secret and apply the manifest. The rehearsal used the local terminal for these commands.
git clone https://github.com/kramit/aks-entra-auth-demo.git
cd aks-entra-auth-demo
export ACR='<registry-name>'
export RG='<aks-resource-group>'
export AKS='<cluster-name>'
export DNS_LABEL='<dns-label>'
export REGION='<azure-region-name>'
export HOSTNAME_PUBLIC="$DNS_LABEL.$REGION.cloudapp.azure.com"
tag=$(git rev-parse --short=12 HEAD)
az acr build -r "$ACR" -t "aks-entra-demo:$tag" .
digest=$(az acr repository show -n "$ACR" --image "aks-entra-demo:$tag" --query digest -o tsv)
registry=$(az acr show -n "$ACR" --query loginServer -o tsv)
image="$registry/aks-entra-demo@$digest"
az aks get-credentials -g "$RG" -n "$AKS"
kubectl create namespace entra-demo
Create an Opaque Secret called entra-demo-settings in entra-demo. Supply TENANT_ID, CLIENT_ID, CLIENT_SECRET, SESSION_SECRET (a cryptographically random value), and PUBLIC_URL (https://<hostname>/). For a Cloud Shell rehearsal, read the credential without terminal echo and pipe the Secret directly to Kubernetes.
read -rp 'Tenant ID: ' tenant_id
read -rp 'Application (client) ID: ' client_id
read -rsp 'Client secret: ' client_secret
printf '\n'
session_secret=$(openssl rand -base64 48)
{
printf 'TENANT_ID=%s\nCLIENT_ID=%s\n' "$tenant_id" "$client_id"
printf 'CLIENT_SECRET=%s\nSESSION_SECRET=%s\n' "$client_secret" "$session_secret"
printf 'PUBLIC_URL=https://%s/\n' "$HOSTNAME_PUBLIC"
} | kubectl -n entra-demo create secret generic entra-demo-settings --from-env-file=/dev/stdin
unset client_secret session_secret
sed -e "s|DEMO_DNS_LABEL|$DNS_LABEL|g" \
-e "s|DEMO_HOSTNAME|$HOSTNAME_PUBLIC|g" \
-e "s|DEMO_IMAGE_REFERENCE|$image|g" kubernetes.yaml |
kubectl -n entra-demo apply -f -
kubectl -n entra-demo rollout status deploy/entra-demo
kubectl -n entra-demo get pods,svc
In the portal, open Workloads > Deployments and confirm 1/1 Ready. Open Services, gateways and ingresses > Services and confirm the web Service is a healthy LoadBalancer with ports 80 and 443.
The public IP and its DNS record can take several minutes to appear. Caddy then requests a public certificate. The manifest uses an in-memory session store for the single demo replica, and pod-local certificate storage. Replicas or frequent replacements need shared session and certificate storage. If the image fails to pull, check the kubelet’s registry access. If HTTPS is pending, check that the hostname resolves to the Service public IP and inspect the https container’s logs.
4. Rehearse the sign-in flow
-
Open
https://<hostname>/in Edge InPrivate. Show that Public landing page opens before sign-in.
-
Select Sign in with Microsoft Entra ID. Sign in as the assigned presenter. Complete any tenant-approved consent and MFA prompts.
-
Show Signed-in user. The server has exchanged the authorization code and created a session. The page renders selected Entra claims.
-
Select Sign out. Complete the Entra account picker if shown. Confirm that the homepage is public again and that opening
/accountstarts a new sign-in.
The rehearsal verified the full browser sequence in Edge InPrivate, including the return to the public homepage and the new Entra sign-in for the protected route.
Costs and repeat runs
The Free tier covers the control plane. The node VMs, disks, Azure Load Balancer, public IPs, registry usage and subscription-level services can still incur charges. Use Stop on the AKS Overview page between classes to stop worker VM compute. Select Start before class and wait for the deployment and HTTPS endpoint to recover. Review residual costs in Cost Management. Remove the dedicated resource group and its Entra registration when finished. A shared ACR stays with its original resource group.
Create AKS in the Azure portal · AKS system pool requirements · AKS and ACR · AKS public load balancer and DNS label






















