7. Troubleshooting and cleanup
View logs
# App Service
az webapp log tail --resource-group $RG --name $APP_NAME
# Container Apps
az containerapp logs show --name ca-containerdemo --resource-group $RG --follow
az containerapp logs show --name ca-containerdemo --resource-group $RG --type system
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| App Service shows "Application Error" or times out on start | Azure is probing the wrong port | Set WEBSITES_PORT=8080 to match ASPNETCORE_HTTP_PORTS. |
| Container Apps returns 502/503 or never becomes ready | --target-port does not match the container |
Update ingress target port to 8080 and redeploy. |
| Image pull fails (unauthorized) | Missing AcrPull role or role not propagated yet |
Check the role assignment, wait a few minutes, then restart. |
| "exec format error" in logs | Image built for ARM64 but host is AMD64 | Rebuild with --platform linux/amd64 or use az acr build. |
| Redirect loop or http links behind HTTPS | Forwarded headers not configured | Set ASPNETCORE_FORWARDEDHEADERS_ENABLED=true as shown in step 3. |
| First request is slow | Cold start (scale to zero, or Always On disabled) | Set min replicas to 1, or enable Always On. |
| App cannot find configuration | Settings only exist on your machine | Provide settings via app settings / environment variables / Key Vault. |
Production checklist
- Use managed identities and Key Vault; keep secrets out of images and source control.
- Add a health endpoint (this site exposes
/healthz) and configure health probes. - Enable Application Insights or Azure Monitor for telemetry.
- Pin base image versions and rebuild regularly for security patches.
- Add custom domains and managed certificates.
Clean up
Deleting the resource group removes everything created in this guide, stopping any charges:
az group delete --name $RG --yes --no-wait