Chapter 5 of 6 · Implementation

Azure Policy guardrails for Microsoft Foundry AI services

Optional module · Draft 4 hours

Chapter 5 of 6

Implement#

1. Complete the decision record#

Edit artifacts/policy/guardrail-decisions.json in the approved private path. Keep the initial effects in audit mode unless the owner has already reviewed the current policy states.

2. Run preflight#

PowerShell

$targetScope = "<approved subscription resource ID>"
$deploymentLocation = "<approved deployment location>"

.\scripts\preflight.ps1 `
  -TargetScope $targetScope `
  -DeploymentLocation $deploymentLocation

Bash

target_scope="<approved subscription resource ID>"
deployment_location="<approved deployment location>"

./scripts/preflight.sh \
  --target-scope "$target_scope" \
  --deployment-location "$deployment_location"

Preflight rejects unresolved decisions, unsupported effects, a mismatched scope, Bicep syntax errors, and a subscription mismatch. After those checks pass, it runs two subscription-scope what-if previews: one for the initiative and custom definition, and one for the assignment.

3. Deploy the initiative and staged assignment#

Deploy the initiative first:

PowerShell

az deployment sub create `
  --location $deploymentLocation `
  --name "optional-ai-services-guardrail-policy-initiative" `
  --template-file .\artifacts\policy\initiative.bicep `
  --parameters .\artifacts\environments\initiative.bicepparam `
  --only-show-errors

Bash

az deployment sub create \
  --location "$deployment_location" \
  --name "optional-ai-services-guardrail-policy-initiative" \
  --template-file ./artifacts/policy/initiative.bicep \
  --parameters ./artifacts/environments/initiative.bicepparam \
  --only-show-errors

Then deploy the assignment:

PowerShell

az deployment sub create `
  --location $deploymentLocation `
  --name "optional-ai-services-guardrail-policy-assignment" `
  --template-file .\artifacts\policy\assignment.bicep `
  --parameters .\artifacts\environments\assignment.bicepparam `
  --only-show-errors

Bash

az deployment sub create \
  --location "$deployment_location" \
  --name "optional-ai-services-guardrail-policy-assignment" \
  --template-file ./artifacts/policy/assignment.bicep \
  --parameters ./artifacts/environments/assignment.bicepparam \
  --only-show-errors

Keep the assignment in DoNotEnforce until current policy states are available and reviewed.

4. Review current compliance by reference#

PowerShell

.\scripts\check-compliance.ps1 -TargetScope $targetScope

Bash

./scripts/check-compliance.sh --target-scope "$target_scope"

The script summarizes live policy states by policy definition reference. It does not export or store live-state data in this repository.

5. Promote approved references#

Update guardrail-decisions.json for the approved promotion. Common changes are:

  • enforcementMode from DoNotEnforce to Default;
  • networkAccess, localAuthentication, or deploymentSku from Audit to Deny; and
  • diagnosticLogs from AuditIfNotExists to DeployIfNotExists.

Set policyStateReviewStatus to Reviewed only after the owner review. Rerun preflight and redeploy the same assignment.

Optional module

Azure Policy guardrails for Microsoft Foundry AI services slide deck