Create custom policies for Microsoft Foundry
This article refers to the Microsoft Foundry (new) portal.
- Enforce governance: Prevent unauthorized creation of Foundry hubs, projects, connections, or capability hosts.
- Control resource behavior: Ensure security configurations, enforce tagging, or allow only approved integrations.
- Ensure compliance: Apply enterprise security and operational standards consistently across environments.
Prerequisites
- An Azure account with an active subscription. If you don’t have one, create a free Azure account, which includes a free trial subscription.
- Access to a role that allows you to complete role assignments, such as Owner. For more information about permissions, see Role-based access control for Microsoft Foundry.
Steps to create a custom policy
-
Open policy in the Azure portal
- Go to Azure portal.
- Search for Policy and select it.
-
Define a new policy
- In the Authoring section, select Definitions > + Policy definition.
- Provide:
- Definition location: Subscription or management group.
- Name: A unique name (for example,
Deny-Unapproved-Connections). - Description: Explain the purpose (for example, “Restrict Foundry connections to approved categories”).
- Category: Use an existing category or create one such as
AI Governance.
-
Add policy rule
- Enter the rule in JSON format. For example, to allow only approved connection categories:
category isn’t in the allowedCategories parameter. It applies to both Microsoft.CognitiveServices/accounts/connections and Microsoft.CognitiveServices/accounts/projects/connections.
To customize the behavior, update allowedCategories (or override it when you assign the policy) with the connection categories your organization approves.
References:
- Reference: Policy definition structure
- Reference: Policy rule structure
- Reference: Policy effects
-
Assign the policy
- After saving, assign the policy to the desired scope (subscription, resource group, or hub).
-
Validate the policy assignment
- Try to create a connection with a category that isn’t in
allowedCategoriesand confirm the request is denied. - Try to create a connection with a category that is in
allowedCategoriesand confirm the request succeeds.
- Try to create a connection with a category that isn’t in
Common custom policy scenarios
-
Allow only approved connection categories
Block any connection category other than those approved by your organization. -
Deny connections that use API keys as the authentication type
Require all other authentication types because API keys are typically less secure. -
Audit Foundry resources without a valid Agent capability host
Check for the existence of a virtual network subnet ARM ID and custom storage resources when using Agent service in a regulated environment. -
Deny creation of account kinds that don’t have full Foundry capabilities
Ensure new accounts are configured so users can access all Foundry capabilities.
Sample library
Explore ready-to-use templates and examples in the GitHub repository:Custom policy definitions This library includes JSON templates for common scenarios.
Next steps
- Review Built-in Policies for Foundry for built-in and custom policies for comprehensive compliance.
- Test policies in a nonproduction environment before enforcing them broadly.
Troubleshooting
- If you can’t create or assign a policy definition, confirm you have the required role at the scope you’re using.
- If a connection isn’t blocked as expected, confirm the policy assignment scope includes the target resource.
- If a policy blocks more resources than expected, review the
allowedCategoriesvalue used in the assignment.