Networking
Azure Network Security Perimeter: validate Enforced mode before cutting a PaaS flow
A production runbook for qualifying public Azure PaaS flows in Transition mode, building minimal NSP rules, canarying Enforced and rolling back without losing evidence.
An Azure storage account still works after it is associated with a Network Security Perimeter in Transition mode. The business API, delivery pipeline and diagnostic exports all continue to pass. The security team now wants Enforced mode so that undeclared public access is actually denied.
The risk is treating the absence of an incident as proof that the profile is complete. In Transition, resource-level network rules can still allow traffic that the perimeter does not recognize. A call allowed by the storage firewall today can therefore fail as soon as the association moves to Enforced. This runbook turns learning logs, dependency inventory and a canary into a decision: enforce, repair the profile, remain in Transition or return to the previous mode.
The running case uses a stordersprod account called by an Azure-hosted API, a delivery runner with stable egress and an operator workstation that must remain denied. The method applies to supported PaaS services, but service coverage and limitations must be checked before each association.
Freeze the traffic contract before the change
Do not begin by copying every resource firewall rule into the NSP profile. Define the useful operations, their sources, direction and expected evidence. An application-level inventory prevents a temporary address or retired subscription from becoming a permanent exception.
change: CHG-2026-1103-14
resource: stordersprod
perimeter: nsp-prod-data
profile: orders
current_mode: Learning
target_mode: Enforced
required_flows:
- name: orders-api-read-write
source: approved-application-subscription
direction: Inbound
operations: [read-order, write-order]
owner: orders-platform
- name: release-runner-deploy
source: stable-egress-cidr
direction: Inbound
operations: [upload-package]
owner: delivery-platform
negative_canary:
source: admin-workstation
expected: denied
rollback_owner: network-on-call
observation_window: 24h Also freeze publicNetworkAccess, firewall rules, private endpoints, diagnostic settings, profile version and current association. In Transition, publicNetworkAccess and resource rules still participate in the decision. In Enforced, perimeter rules govern public traffic. Without the before state, rollback restores a mode but not necessarily a known behavior.
Inventory the effective association and rules
The az network perimeter commands are provided by the Azure CLI nsp extension. Keep the raw JSON outputs with the change record and verify provisioningState before interpreting data-plane tests.
set -eu
RG="rg-network-security-prod"
NSP="nsp-prod-data"
PROFILE="orders"
az extension add --name nsp --upgrade --only-show-errors
az network perimeter association list --resource-group "$RG" --perimeter-name "$NSP" --output json > nsp-associations-before.json
az network perimeter profile access-rule list --resource-group "$RG" --perimeter-name "$NSP" --profile-name "$PROFILE" --output json > nsp-rules-before.json
az network perimeter logging-configuration list --resource-group "$RG" --perimeter-name "$NSP" --output json > nsp-logging-before.json Map every rule to a flow in the contract. A subscription rule is appropriate only when the whole subscription is an acceptable source. An IP range is defensible only when its owner, stability and NAT path are known. FQDN rules apply to supported outbound flows; they do not replace caller identity for inbound access.
Private Endpoint has a precise role: it provides a private path, and its traffic is not evaluated as public access by NSP access rules. Its presence proves neither that the public path is closed nor that the remaining required public flows are complete.
Make learning observable before Enforced
Enable the required log categories on the perimeter and send them to a destination compatible with the target topology. If Log Analytics, Storage or Event Hubs stores the evidence, verify its own perimeter behavior before relying on it to validate this change.
In Transition, three classes matter: traffic allowed by an NSP rule, traffic not recognized by NSP but allowed by resource rules, and traffic already denied by the resource. The second class exposes successful calls that would become denies after enforcement.
let Start = ago(24h);
NSPAccessLogs
| where TimeGenerated >= Start
| where ServiceResourceId =~ "<storage-resource-id>"
| where TrafficType == "Public"
| summarize Events=sum(Count),
FirstSeen=min(TimeGenerated),
LastSeen=max(TimeGenerated)
by Category, ResultAction, ResultDirection,
SourceIpAddress, SourceResourceId, SourceAppId,
Profile, MatchedRule, ServiceFqdn
| order by Events desc Do not turn every observed source into a rule. Group events by use case and require the owner to prove the dependency. An address seen once may belong to a test, scanner or bypass path that should disappear.
Find future denies, not only current errors
In Transition, NspPublicInboundResourceRulesAllowed means the NSP profile did not allow the flow but resource rules did. This is the priority set to qualify before Enforced. NspPublicInboundResourceRulesDenied captures access already rejected by the resource. It can support the negative canary, but it does not justify a new rule.
let Start = ago(24h);
NSPAccessLogs
| where TimeGenerated >= Start
| where ServiceResourceId =~ "<storage-resource-id>"
| where Category in (
"NspPublicInboundResourceRulesAllowed",
"NspPublicOutboundResourceRulesAllowed")
| summarize Events=sum(Count),
Operations=make_set(OperationName, 20),
FirstSeen=min(TimeGenerated),
LastSeen=max(TimeGenerated)
by ResultDirection, SourceIpAddress, SourceResourceId,
SourceAppId, DestinationFqdn, Profile
| order by Events desc A quiet window is not sufficient evidence. Cover scheduled processing, rotations, exports, recovery paths and one delivery cycle. If a rare flow is critical, trigger it deliberately with a correlation identifier before cutover.
Build the smallest rule and replay the cases
Add one rule at a time through IaC or the approved change mechanism. Its name should identify the owner and purpose, not only an address. After propagation, replay the positive flow and verify that MatchedRule identifies the expected rule. Azure may take several minutes to apply a change; do not decide from the first failure after the control-plane write.
CASE SOURCE EXPECTED RESULT
API read and write API identity/subscription authorised by named NSP rule
Package delivery stable runner egress CIDR authorised by named NSP rule
Routine administration operator workstation denied
Unknown source out-of-scope runner denied
Existing private path workload through Private Link allowed as private traffic
Logging NSP to log destination events received and queryable
ENFORCED GATE
Every positive flow has an owner and minimal rule
Every negative canary is denied
No critical success still depends on a resource rule
Logs remain available from the target topology
A named owner can execute rollback Check outbound direction when the PaaS service sends to an external destination. A profile that fully covers inbound calls can still break a webhook, export or notification. Qualify the destination FQDN, operation and owner rather than adding a wildcard.
Canary Enforced on one association
Access mode belongs to the resource association. This provides a useful canary boundary: move one representative resource without enforcing every resource attached to the profile. Use the exact association, profile and PaaS resource identifiers captured during inventory.
set -eu
RG="rg-network-security-prod"
NSP="nsp-prod-data"
ASSOCIATION="stordersprod-association"
RESOURCE_ID="<storage-resource-id>"
PROFILE_ID="<nsp-profile-resource-id>"
az network perimeter association update --resource-group "$RG" --perimeter-name "$NSP" --name "$ASSOCIATION" --access-mode Enforced --private-link-resource id="$RESOURCE_ID" --profile id="$PROFILE_ID" --change-reference "CHG-2026-1103-14" --output json Wait for propagation, then run canaries from their real environments. A request from Cloud Shell represents neither the production API NAT address, identity nor DNS resolution. Correlate the client result, resource logs and NSPAccessLogs in the same UTC window.
Decide, expand or roll back
Expand Enforced only when positive flows use named NSP rules, negative canaries are denied and no business signal regresses. New NspPublicInboundPerimeterRulesDenied events should map to deliberately unauthorized sources. A deny without an owner is not automatically noise; it is a dependency to qualify before any exception.
The immediate rollback is to return the association to Learning, then replay the same canaries. That restores the role of resource-level rules for public traffic. It does not repair a firewall rule, DNS path or identity changed in parallel, which is why this change must remain isolated.
az network perimeter association update --resource-group "rg-network-security-prod" --perimeter-name "nsp-prod-data" --name "stordersprod-association" --access-mode Learning --private-link-resource id="<storage-resource-id>" --profile id="<nsp-profile-resource-id>" --change-reference "CHG-2026-1103-14-ROLLBACK" --output json After rollback, preserve deny events, rule version and correlation identifiers. Repair the contract or minimal rule, collect another representative learning window, and schedule the canary again. Do not widen an IP range or disable the perimeter to make an unknown dependency disappear.
Conclusion
Moving a Network Security Perimeter to Enforced is not an administrative toggle. It changes the decision engine for public traffic to a PaaS resource. The useful evidence is in successful Transition traffic that still depends on resource rules, not only in visible failures.
The closing decision should be operationally clear: promote Enforced because every required flow maps to a minimal rule and every negative canary is denied, or return to Learning with the evidence needed to repair the profile. The perimeter then becomes a testable control rather than a compliance label.