Provider capabilities
The following table shows which actions each provider supports:| Action | AzAPI Provider | AzureRM Provider |
|---|---|---|
| Create a resource group | ✅ | ✅ |
| Create a Foundry resource | ✅ | ✅ |
| Configure deployments | ✅ | ✅ |
| Configure projects | ✅ | ✅ |
| Configure a connection to knowledge and tools | ✅ | - |
| Configure a capability host (for advanced tool configurations like Agent standard setup) | ✅ | - |
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 create a Foundry resource, such as Foundry Account Owner or Foundry Owner on the subscription or resource group. For more information about permissions, see Role-based access control for Microsoft Foundry.
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
Create a basic Foundry configuration
- AzAPI Provider
- AzureRM Provider
- Create a directory to test and run the sample Terraform code. Make this directory your current directory.
-
Create a file named
providers.tfand add the following code. -
Create a file named
main.tfand add the following code. -
Create a file named
variables.tfand add the following code.
Initialize Terraform
Create a Terraform execution plan
Apply a Terraform execution plan
Verify your deployment
Run the following commands to verify deployed resources:Export an existing resource to Terraform
If you already configured a Foundry resource in the Azure portal, you can export that configuration as Terraform code. The export captures your current resource settings, including network rules, identity configuration, and project associations. Use the exported code as a starting point for managing the resource with Terraform.- In the Azure portal, go to your Foundry resource.
- In the left menu, expand Automation, and then select Export template.

- Select the Terraform tab to view the generated Terraform code. Use the AzureRM or AzApi subtab to choose which provider format to export.

- Select Download to save the file locally, Open in VS Code to edit it directly, or Copy to copy the code to your clipboard.
The export might complete with warnings if some resource types don’t support full export. Review the output and fill in any missing properties manually.
Import the exported resource into Terraform state
To manage the exported resource with Terraform going forward, import it into your Terraform state. For the AzAPI provider:<resource-id> with the full Azure resource ID shown in the exported file (for example, /subscriptions/.../providers/Microsoft.CognitiveServices/accounts/<name>).
Customize the exported configuration
The exported Terraform code contains hardcoded values specific to your subscription and resource group. Before you reuse the configuration:- Replace hardcoded subscription IDs, resource group names, and resource IDs with Terraform variables.
- Remove any properties you don’t need or that reference resources outside the deployment scope.
- Add or adjust security configurations to match your organization’s requirements.
Related security configurations
When you customize your configuration, consider adding the following security settings. Choose based on your governance requirements:| Control | When to add it | Learn more |
|---|---|---|
| Private endpoints (network isolation) | Your organization bans public endpoints, or you need to keep traffic on your virtual network for compliance (HIPAA, PCI, FedRAMP). | Configure network isolation with private endpoints |
| Customer-managed keys (CMK) for encryption | You must control the encryption-key lifecycle, rotation cadence, or revocation, or your data classification requires bring-your-own-key. | Set up customer-managed keys for encryption |
| Role-based access control (RBAC) | You need least-privilege access for builders versus administrators, or you grant access to multiple teams that share a Foundry resource. | Configure role-based access control for Foundry |
| Custom Azure Policy definitions | Your platform team enforces a security baseline (allowed regions, required tags, allowed SKUs, mandatory CMK or private link) across every Foundry resource the organization creates. | Create custom Azure Policy definitions |
Customize security and compliance
To meet security and compliance requirements, customize Foundry with security configurations and by bringing your own storage resources. For example, when using the Agent service, you can opt to bring your own Azure Cosmos DB database, Azure AI Search instance, and Azure Storage Account to store your threads and messages. For advanced setup samples, see the following repositories:- Foundry Samples repository contains example Terraform configurations for the most common enterprise security configurations.
- Terraform Azure Verified Module (Cognitive Services account) is a generic module set to manage the Azure resource type used by Foundry, Azure OpenAI, Azure Speech, Azure Language.
- Terraform Azure Verified Pattern Module (Foundry) is a reference implementation for Foundry.
- Terraform Azure Verified Pattern Module (Azure AI and ML Landing Zone) provides a reference for the set of resources typically created alongside Foundry for an end-to-end sample.