Skip to content

feat(ai project): add model deployment Azure Policy pre-checks and warnings - #10902

Open
Zhijie Huang (hund030) wants to merge 2 commits into
mainfrom
feat/project-model-policy-preflight
Open

Zhijie Huang (hund030) wants to merge 2 commits into
mainfrom
feat/project-model-policy-preflight

Conversation

@hund030

@hund030 Zhijie Huang (hund030) commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Microsoft Foundry model deployments added or provisioned against an existing project with active Azure Policy Deny assignments fail late during ARM template execution without Foundry Govern remediation links. This PR adds ARM evaluateDeploymentPolicies pre-checks, brownfield reconciliation warnings, and runtime ARM policy denial guidance in azure.ai.projects.

Changes

  • internal/provisioning/model_policy.go: Evaluate model deployments via POST <accountId>/evaluateDeploymentPolicies?api-version=2026-03-15-preview (resolving missing metadata via GET <accountId>/deployments/<name>), block only on Deny (Audit is non-blocking), honor AZD_AI_AGENT_SKIP_POLICY_CHECKS, and generate Foundry Govern portal deep links.
  • internal/cmd/project_deployment_add.go, internal/provisioning/foundry_provisioning_provider.go: Hard-block policy-denied models (CodeModelBlockedByPolicy) before mutating azure.yaml/.env in azd ai project deployment add or submitting ARM deployments in azd provision.
  • internal/cmd/project_deployment_reconcile.go, internal/exterrors/errors.go: Emit non-blocking policy warnings during azd ai project add brownfield deployment reconciliation and enrich runtime ARM RequestDisallowedByPolicy / PolicyViolation errors.

Manual Validation

  • Installed azure.ai.projects locally via azd x build and tested against xiaofhua-tool-policy-project (which enforces xh-model-deny-policy with Deny and xh-model-audit-policy with Audit).
  • Ran azd ai project deployment add and azd provision --no-prompt with denied model OpenAI/text-embedding-3-small; verified both hard-blocked with model_blocked_by_policy and the Foundry Govern link, while compliant/audited OpenAI/gpt-4.1 and AZD_AI_AGENT_SKIP_POLICY_CHECKS=true succeeded.
  • Ran azd ai project add --project-id <id> --no-prompt with existing denied deployment text-embedding-3-small in azure.yaml; verified project adoption succeeded and printed the non-blocking Azure Policy warning with the Govern link.

Screen Shots

image image

…rnings

- Pre-check model deployments via ARM \�valuateDeploymentPolicies\ before writing config in \�zd ai project deployment add\ or submitting ARM deployments in \�zd provision\.

- Emit non-blocking policy warnings with Foundry Govern links when reconciling adopted deployments in \�zd ai project add\ and enrich runtime ARM policy denial errors.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
25 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Policy checks can evaluate the wrong project or stale models, miss existing accounts and nested denials, and leave configuration changes behind after a rejected deployment.

7 open issues
What changed in this PR

Adds Azure Policy pre-checks and denial diagnostics to model deployment workflows in the azure.ai.projects extension.

Changes:

  • Evaluate model deployments before submission, blocking on Deny while allowing Audit, with opt-out settings and Foundry Govern links.
  • Integrate blocking checks into deployment authoring and provisioning, plus non-blocking warnings during existing-project adoption.
  • Add structured policy errors, runtime ARM denial guidance, and unit tests.

Extension user-contract review: blocked (10 files inspected; 0 new contract comments; 0 matched threads; prior review history unavailable).

File Description
cli/​azd/​extensions/​azure.ai.projects/​internal/​provisioning/​model_policy.go Implements policy evaluation, metadata lookup, opt-outs, links, and messages.
cli/​azd/​extensions/​azure.ai.projects/​internal/​provisioning/​model_policy_test.go Tests evaluation, batching, metadata resolution, and provisioning checks.
cli/​azd/​extensions/​azure.ai.projects/​internal/​provisioning/​foundry_provisioning_provider.go Invokes policy checks before ARM deployment submission.
cli/​azd/​extensions/​azure.ai.projects/​internal/​exterrors/​errors.go Adds runtime policy-denial guidance and assignment extraction.
cli/​azd/​extensions/​azure.ai.projects/​internal/​exterrors/​errors_test.go Tests guidance for ARM policy-denial responses.
cli/​azd/​extensions/​azure.ai.projects/​internal/​exterrors/​codes.go Defines the model-policy blocking error code.
cli/​azd/​extensions/​azure.ai.projects/​internal/​cmd/​project_deployment_reconcile.go Adds non-blocking policy warnings during deployment reconciliation.
cli/​azd/​extensions/​azure.ai.projects/​internal/​cmd/​project_deployment_reconcile_test.go Tests reconciliation warnings and partial evaluation failures.
cli/​azd/​extensions/​azure.ai.projects/​internal/​cmd/​project_deployment_add.go Checks the selected model before deployment-specific writes.
cli/​azd/​extensions/​azure.ai.projects/​internal/​cmd/​project_deployment_add_test.go Tests policy rejection without deployment-specific mutations.

Review effort: Max

- Route reconciliation policy warnings through injected \stderr\ writer (suppressed for \json\/\
one\), unwrap \properties.error\ ARM polling envelopes, and resolve \projectResourceId\/\deployments\ authoritatively from resolved template parameters.

- Reject trailing empty segments on resource IDs and document model policy checks and \AZD_AI_AGENT_SKIP_POLICY_CHECKS\ in \README.md\.
Copilot AI max review requested due to automatic review settings November 11, 2026 09:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +298 to +299
if src != nil && src.parameters != nil {
return projectID, decodeModelDeploymentsValue(resolveTemplateParameterValue(src, "deployments"))
log.Printf("[FoundryPolicy] Could not resolve model metadata for deployment %q: %v", dep.Name, err)
continue
}
if fetched != nil {
Comment on lines +439 to +440
if target == nil || strings.TrimSpace(target.ResourceId) == "" ||
provisioning.ShouldSkipModelPolicyChecks(environmentValues) {
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

azure.ai.projects PR build

Note

This is an unsigned development build. Install it only if you trust this PR.

Install the extension:

azd ext install "https://azuresdkartifacts.z5.web.core.windows.net/azd/extensions/pr/10902/azure-ai-projects.zip"
  • Version: 1.0.0-pr.10902.7063894
  • Merge commit: 070a63d

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-projects azure.ai.projects extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants