Networking
Azure App Service: diagnose an access restriction before opening the public endpoint
A production runbook for separating publicNetworkAccess, main and SCM rules, source identity, Front Door headers and audit logs when App Service returns 403.
An Azure App Service API starts returning 403 immediately after its inbound access is hardened. Azure Front Door still sees a reachable origin, the application release has not changed, and direct calls from an operator workstation fail too. The fastest workaround appears to be enabling public access or changing the unmatched action to Allow.
That restores traffic by removing the control that failed. It does not explain whether the request was stopped by publicNetworkAccess, a rule on the main site, a different rule on the SCM site, a stale source address, a broad Service Tag, or a missing Front Door identifier. The running case is an API whose default endpoint must accept only one Front Door profile while deployment continues through a separately restricted SCM endpoint. The goal is to identify the exact decision boundary, canary one minimal correction, and either promote it or restore the previous ruleset.
Freeze one failed request and both access contracts
Capture evidence before reordering rules. Record the UTC window, hostname, path, HTTP status, Front Door profile and origin, deployment slot, caller path, last approved ruleset, and a correlation value that is safe to log. Preserve the main site and SCM contracts separately.
incident: INC-NET-274
observed_utc: 2026-10-22T05:55:00Z
app_service: api-orders-prod
slot: production
request:
entry_path: azure-front-door
host: api.example.net
path: /health/ready
status: 403
correlation_id: access-canary-71d9
expected_main_site:
public_network_access: Enabled
allowed_front_door_profile: <front-door-resource-guid>
unmatched_action: Deny
expected_scm_site:
inherit_main_rules: false
deployment_source: <runner-cidr-or-subnet>
unmatched_action: Deny
rollback:
ruleset_commit: <last-approved-commit>
export: app-service-access-before.json Keep the failed route intact long enough to observe it. A restart or redeployment is not a network diagnosis, and it can erase the deployment and configuration timestamps needed to reconstruct the change.
Separate app access from site access
App Service has two different gates on the default endpoint. publicNetworkAccess decides whether that entry point is available. Site access restrictions then evaluate ordered allow and deny rules for the main site and, independently, the SCM or Kudu site.
Export all three surfaces from the affected slot. Do not infer production state from a staging slot or from IaC alone.
set -euo pipefail
RG="rg-app-prod"
APP="api-orders-prod"
SLOT="production"
if [ "$SLOT" = "production" ]; then
APP_ID=$(az webapp show -g "$RG" -n "$APP" --query id -o tsv)
SLOT_ARGS=()
else
APP_ID=$(az webapp deployment slot show -g "$RG" -n "$APP" --slot "$SLOT" --query id -o tsv)
SLOT_ARGS=(--slot "$SLOT")
fi
az resource show --ids "$APP_ID" --api-version 2024-04-01 --query '{publicNetworkAccess:properties.publicNetworkAccess,state:properties.state}' --output jsonc
az webapp config access-restriction show -g "$RG" -n "$APP" "${SLOT_ARGS[@]}" --output json > app-service-access-before.json
jq '{main:.ipSecurityRestrictions,
mainDefault:.ipSecurityRestrictionsDefaultAction,
scm:.scmIpSecurityRestrictions,
scmDefault:.scmIpSecurityRestrictionsDefaultAction,
scmUsesMain:.scmIpSecurityRestrictionsUseMain}' app-service-access-before.json An unavailable default endpoint is not repaired by adding another site rule. Conversely, an enabled endpoint does not mean the request is allowed. Treat a null setting as effective platform behavior that must be recorded, not as proof that the endpoint is explicitly enabled.
Private Endpoint is a separate inbound path. Traffic entering through it bypasses App Service access restrictions, so a successful private canary does not validate the public default endpoint. If a private endpoint exists, note its role and test it independently; do not use it to explain a Front Door request unless Front Door is actually configured to use that origin path.
Reconstruct the ordered rule decision
Rules are evaluated from the lowest priority number upward. Equal priorities create an avoidable dependency on returned order. When at least one rule exists and no explicit unmatched action is configured, unmatched traffic is denied implicitly.
Build a compact decision table from the export.
Default endpoint disabled
publicNetworkAccess blocks the path before site allow rules can restore it
Front Door Service Tag only
AzureFrontDoor.Backend proves the Azure Front Door source range
It does not identify the approved profile
Service Tag plus X-Azure-FDID
Both the source rule and header value must match
Compare the configured value with the profile resource GUID
Subnet service-endpoint rule
Verify the real source subnet and Microsoft.Web service endpoint
Do not confuse this with VNet Integration, which is outbound
Main site passes, SCM fails
Inspect scmIpSecurityRestrictions and its default action
Decide explicitly whether SCM should inherit main rules
No rule matches
Read the explicit or implicit unmatched action
Do not append a broad allow to prove reachability For Front Door, the safe contract normally combines the AzureFrontDoor.Backend Service Tag with the expected X-Azure-FDID. The Service Tag alone admits the backend ranges used by the service, not only one profile. A client-supplied header alone is not a trusted source boundary.
Use audit logs without overclaiming absence
Enable the AppServiceIPSecAuditLogs resource log category before an incident if it is part of the operating model. It records requests that match explicit allow or deny rules and exposes the observed client IP, host, result, Service Endpoint state and supported proxy headers.
let start = ago(30m);
AppServiceIPSecAuditLogs
| where TimeGenerated >= start
| where _ResourceId has "/sites/api-orders-prod"
| project TimeGenerated, Result, CIp, CsHost,
XAzureFDID, XFDHealthProbe, XForwardedFor,
ServiceEndpoint, Details, _ResourceId
| order by TimeGenerated desc An explicit deny is strong evidence. No row is weaker: the unmatched rule is not logged as a matched rule, diagnostic settings may be missing, ingestion can be delayed, or the request may have been stopped before site-rule evaluation. Correlate the same window with Front Door access and health-probe logs, App Service HTTP logs, Activity Log changes, and application logs.
Canary one minimal correction
Make one change only after the failed decision is attributable. Typical corrections are restoring the expected Front Door profile ID, fixing one rule priority, adding the actual deployment source to SCM, or restoring the previously approved default action. Do not change publicNetworkAccess, main rules, SCM inheritance and Front Door origin settings together.
For a Front Door rule, generate and review a command like this in a nonproduction slot or a bounded change window:
az webapp config access-restriction add --resource-group "$RG" --name "$APP" "${SLOT_ARGS[@]}" --rule-name "allow-approved-front-door" --priority 100 --action Allow --service-tag AzureFrontDoor.Backend --http-header x-azure-fdid=<front-door-resource-guid>
az webapp config access-restriction show -g "$RG" -n "$APP" "${SLOT_ARGS[@]}" --output json > app-service-access-candidate.json Run four controls against a harmless endpoint: the approved Front Door profile must pass; a second profile must remain denied; a direct public call must remain denied; and the approved deployment runner must still reach SCM according to its separate contract. Confirm health probes as well as user requests, because a rule that admits one but not the other can make the origin oscillate.
Decide, validate and roll back
Promote only when the candidate ruleset has unique priorities, an explicit unmatched action, the expected main and SCM behavior, and correlated audit evidence. Save the effective post-change export next to the reviewed IaC diff.
Rollback means restoring the complete previous contract, not adding an emergency Allow rule above a broken policy. Reapply the last approved publicNetworkAccess value, main restrictions, SCM restrictions, inheritance setting and default actions. Remove the canary rule, then replay all four controls. If the old contract no longer works because the source or Front Door profile changed, hold the rollback and update the inventory before opening traffic.
Conclusion
An App Service 403 after network hardening is a policy decision to reconstruct, not a reason to expose the application. Separate endpoint availability from ordered site rules, keep main and SCM contracts distinct, and prove both the network source and the Front Door profile.
The recovery decision is complete only when the expected path passes, the bypass paths remain denied, the effective configuration is versioned, and the previous ruleset can still be restored and tested.