Skip to content

Azure/terraform-azurerm-avm-ptn-aiml-ai-foundry

Repository files navigation

Azure AI Foundry Terraform Pattern Module

This Azure Verified Module (AVM) Pattern deploys a complete AI Foundry infrastructure on Azure, providing a production-ready platform for AI applications with supporting services and configurable network isolation.

Key Features

  • AI Foundry Account & Project: Core cognitive services with project workspace and OpenAI model deployments
  • Bring Your Own Resources (BYOR): Conditional deployment of Storage, Key Vault, Cosmos DB, and AI Search
  • Network Isolation: Private endpoints and VNet integration support for enterprise security
  • Three Example Configurations: Basic (minimal), Standard Public (full features), Standard Private (enterprise-grade)

Architecture

The module uses a conditional deployment pattern where dependent services can be:

  • Created new (*_resource_id = null) - Creates new resources (default behavior)
  • Use existing (*_resource_id = "/subscriptions/.../resource-id") - Uses provided existing resources
Feature Basic Standard Public Standard Private
AI Foundry ✅ Public ✅ Public ✅ Private
Storage/Key Vault/Cosmos/Search ❌ Not created ✅ New Public ✅ New Private
Private Endpoints ✅ All services
VNet & Management ✅ Bastion & VM
Use Case Development, PoC Production Enterprise, regulated

Integration

This module can be used independently or as part of the broader AI/ML platform when combined with the AI Landing Zone Accelerator module.

Requirements

The following requirements are needed by this module:

Resources

The following resources are used by this module:

Required Inputs

The following input variables are required:

Description: The name prefix for the AI Foundry resources. Will be used as base_name if base_name is not provided.

Type: string

Description: Azure region where the resource should be deployed.

Type: string

Optional Inputs

The following input variables are optional (have default values):

Description: (Optional) The subnet ID for the AI agent service. If not provided, managed network will be used for the AI agent service. If provided, the AI agent service will be deployed in the specified subnet.

Type: string

Default: null

Description: Description for the AI Foundry project.

Type: string

Default: "AI Foundry project for agent services and AI workloads"

Description: Configuration for AI model deployments (including OpenAI). Each deployment includes:

  • name - The name of the deployment
  • rai_policy_name - (Optional) The name of the RAI policy
  • version_upgrade_option - (Optional) How to handle version upgrades (default: "OnceNewDefaultVersionAvailable")
  • model - The model configuration:
    • format - The format of the model (e.g., "OpenAI")
    • name - The name of the model to deploy
    • version - The version of the model
  • scale - The scaling configuration:
    • type - The scaling type (e.g., "Standard")
    • capacity - (Optional) The capacity of the deployment
    • family - (Optional) The family of the deployment
    • size - (Optional) The size of the deployment
    • tier - (Optional) The pricing tier for the deployment

Type:

map(object({
    name                   = string
    rai_policy_name        = optional(string)
    version_upgrade_option = optional(string, "OnceNewDefaultVersionAvailable")
    model = object({
      format  = string
      name    = string
      version = string
    })
    scale = object({
      capacity = optional(number)
      family   = optional(string)
      size     = optional(string)
      tier     = optional(string)
      type     = string
    })
  }))

Default: {}

Description: (Optional) The resource ID of an existing AI Search service to use. If not provided, a new AI Search service will be created.

Type: string

Default: null

Description: (Optional) The resource ID of an existing Cosmos DB account to use. If not provided, a new Cosmos DB account will be created.

Type: string

Default: null

Description: Whether to create an AI agent service using AzAPI capability hosts.

Type: bool

Default: false

Description: Whether to create dependent resources such as AI Search, Cosmos DB, Key Vault, and Storage Account. If set to false, resource ids of existing resources must be provided (BYOR).

Type: bool

Default: false

Description: Whether to create private endpoints for AI Foundry, Cosmos DB, Key Vault, and AI Search. If set to false, private endpoints will not be created.

Type: bool

Default: false

Description: Whether to create connections to the AI Foundry project. If set to true, connections will be created for the dependent AI Foundry resources. If set to false, no connections will be created.

Type: bool

Default: false

Description: Whether to create a new resource group. Set to false to use an existing resource group specified in resource_group_name.

Type: bool

Default: false

Description: This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.

Type: bool

Default: true

Description: Controls the Resource Lock configuration for this resource. The following properties can be specified:

  • kind - (Required) The type of lock. Possible values are "CanNotDelete" and "ReadOnly".
  • name - (Optional) The name of the lock. If not specified, a name will be generated based on the kind value. Changing this forces the creation of a new resource.

Type:

object({
    kind = string
    name = optional(string, null)
  })

Default: null

Description: (Optional) The resource ID of the existing private DNS zone for AI Foundry.

Type: string

Default: null

Description: (Optional) The resource ID of the existing private DNS zone for Cosmos DB.

Type: string

Default: null

Description: (Optional) The resource ID of the existing private DNS zone for Key Vault.

Type: string

Default: null

Description: (Optional) The resource ID of the existing private DNS zone for AI Search.

Type: string

Default: null

Description: (Optional) The resource ID of the existing private DNS zone for Storage Blob.

Type: string

Default: null

Description: (Optional) The subnet ID for private endpoints.

Type: string

Default: null

Description: The full resource ID of the resource group. When provided, this takes precedence over resource_group_name. Useful for cross-subscription deployments or when the exact resource ID is known. Format: '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}'

Type: string

Default: null

Description: The name for the resource group. When create_resource_group=true, this will be the name of the new resource group. When create_resource_group=false, this must be the name of an existing resource group.

Type: string

Default: null

Description: Custom names for each resource. If not provided, names will be generated using base_name or name.

Type:

object({
    ai_agent_host                   = optional(string)
    ai_foundry                      = optional(string)
    ai_foundry_project              = optional(string)
    ai_foundry_project_display_name = optional(string)
    ai_search                       = optional(string)
    cosmos_db                       = optional(string)
    key_vault                       = optional(string)
    resource_group                  = optional(string)
    storage_account                 = optional(string)
  })

Default: {}

Description: A map of role assignments to create on this resource. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

  • role_definition_id_or_name - The ID or name of the role definition to assign to the principal.
  • principal_id - The ID of the principal to assign the role to.
  • description - The description of the role assignment.
  • skip_service_principal_aad_check - If set to true, skips the Azure Active Directory check for the service principal in the tenant. Defaults to false.
  • condition - The condition which will be used to scope the role assignment.
  • condition_version - The version of the condition syntax. Valid values are '2.0'.
  • delegated_managed_identity_resource_id - The delegated Azure Resource Id which contains a Managed Identity. Changing this forces a new resource to be created.
  • principal_type - The type of the principal_id. Possible values are User, Group and ServicePrincipal. Changing this forces a new resource to be created. It is necessary to explicitly set this attribute when creating role assignments if the principal creating the assignment is constrained by ABAC rules that filters on the PrincipalType attribute.

Note: only set skip_service_principal_aad_check to true if you are assigning a role to a service principal.

Type:

map(object({
    role_definition_id_or_name             = string
    principal_id                           = string
    description                            = optional(string, null)
    skip_service_principal_aad_check       = optional(bool, false)
    condition                              = optional(string, null)
    condition_version                      = optional(string, null)
    delegated_managed_identity_resource_id = optional(string, null)
    principal_type                         = optional(string, null)
  }))

Default: {}

Description: (Optional) The resource ID of an existing storage account to use. If not provided, a new storage account will be created.

Type: string

Default: null

Description: (Optional) Tags to be applied to all resources.

Type: map(string)

Default: null

Outputs

The following outputs are exported:

Description: The resource ID of the AI agent capability host.

Description: The resource ID of the AI Foundry account.

Description: The name of the AI Foundry account.

Description: The resource ID of the AI Foundry Project.

Description: The internal ID of the AI Foundry project used for container naming.

Description: The name of the AI Foundry Project.

Description: The principal ID of the AI Foundry project's system-assigned managed identity.

Description: The resource IDs of all AI model deployments.

Description: The resource ID of the AI Search service.

Description: The name of the AI Search service.

Description: The resource ID of the Cosmos DB account.

Description: The name of the Cosmos DB account.

Description: The resource ID of the Key Vault.

Description: The name of the Key Vault.

Description: The project ID formatted as GUID for container naming (only available when AI agent service is enabled).

Description: The resource ID of the resource group.

Description: The name of the resource group.

Description: The resource ID of the primary AI Foundry project resource.

Description: The resource ID of the storage account.

Description: The name of the storage account.

Modules

The following Modules are called:

Source: ./modules/ai-foundry

Version:

Source: ./modules/ai-foundry-project

Version:

Source: ./modules/dependent-resources

Version:

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.