Edit

Share via


Control AI model deployment with built-in policies in Microsoft Foundry portal

Note

This document refers to the Microsoft Foundry (classic) portal.

🔍 View the Microsoft Foundry (new) documentation to learn about the new portal.

Use Azure Policy to control which AI models your developers can deploy in Foundry portal. This article shows how to assign the built-in policy for Managed Foundry Tools (serverless API deployment) and Model-as-a-Platform (MaaP) models.

Tip

The steps in this article govern the deployment of MaaS and MaaP models for both a Foundry project and hub-based project.

Prerequisites

Enable the policy

You can assign the policy by using Bicep or the Azure portal.

Note

The policy is named "[Preview]: Azure Machine Learning Deployments should only use approved Registry Models" because Foundry uses the Azure Machine Learning resource provider for model deployments.

Use the following Bicep template to assign the policy to a resource group. This example allows only the gpt-35-turbo model from the azure-openai registry.

  1. Save the following code as main.bicep.

    targetScope = 'resourceGroup'
    
    param policyAssignmentName string = 'allowed-models-assignment'
    param allowedModelPublishers array = []
    param allowedAssetIds array = [
      'azureml://registries/azure-openai/models/gpt-35-turbo/versions/3'
    ]
    
    // Policy Definition ID for "[Preview]: Azure Machine Learning Deployments should only use approved Registry Models"
    var policyDefinitionId = '/providers/Microsoft.Authorization/policyDefinitions/12e5dd16-d201-47ff-849b-8454061c293d'
    
    resource policyAssignment 'Microsoft.Authorization/policyAssignments@2024-04-01' = {
      name: policyAssignmentName
      properties: {
        policyDefinitionId: policyDefinitionId
        parameters: {
          allowedModelPublishers: {
            value: allowedModelPublishers
          }
          allowedAssetIds: {
            value: allowedAssetIds
          }
        }
        displayName: 'Allow specific AI models'
        description: 'This policy assignment restricts AI model deployments to the specified list.'
      }
    }
    
  2. Deploy the Bicep file by using Azure CLI.

    az deployment group create --resource-group <your-resource-group> --template-file main.bicep
    

    Replace <your-resource-group> with the name of your resource group. On success, the command returns JSON with "provisioningState": "Succeeded".

  3. Verify the policy assignment.

    az policy assignment show --name allowed-models-assignment --resource-group <your-resource-group>
    
  4. Notify your developers that the policy is in place. They receive an error message if they try to deploy a model that isn't in the list of allowed models.

Reference:

Monitor compliance

To monitor compliance with the policy, follow these steps:

  1. From the Azure portal, select Policy from the left side of the page. You can also search for Policy in the search bar at the top of the page.
  2. From the left side of the Azure Policy Dashboard, select Compliance. Each policy assignment is listed with the compliance status. To view more details, select the policy assignment.

Update the policy assignment

To update an existing policy assignment with new models, follow these steps:

  1. From the Azure portal, select Policy from the left side of the page. You can also search for Policy in the search bar at the top of the page.
  2. From the left side of the Azure Policy Dashboard, select Assignments and find the existing policy assignment. Select the ellipsis (...) next to the assignment and select Edit assignment.
  3. From the Parameters tab, update the Allowed models parameter with the new model IDs.
  4. From the Review + Save tab, select Save to update the policy assignment.

Best practices

  • Granular scoping: Assign policies at the appropriate scope to balance control and flexibility. For example, apply at the subscription level to control all resources in the subscription, or apply at the resource group level to control resources in a specific group.
  • Policy naming: Use a consistent naming convention for policy assignments to make it easier to identify the purpose of the policy. Include information such as the purpose and scope in the name.
  • Documentation: Keep records of policy assignments and configurations for auditing purposes. Document any changes you make to the policy over time.
  • Regular reviews: Periodically review policy assignments to ensure they align with your organization's requirements.
  • Testing: Test policies in a nonproduction environment before applying them to production resources.
  • Communication: Make sure developers are aware of the policies in place and understand the implications for their work.

Troubleshooting

Issue Solution
Policy doesn't block deployments Verify the policy assignment scope includes the target resource group. Check that the effect is set to Deny, not Audit.
Model ID not recognized Ensure the model ID is an exact match, including the version number (for example, azureml://registries/azure-openai/models/gpt-35-turbo/versions/3).
Policy assignment fails Confirm you have the Owner or Resource Policy Contributor role at the target scope.
Changes don't take effect immediately Policy evaluation can take up to 30 minutes. To force evaluation, use az policy state trigger-scan.