Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This directory is owned by @azure-ai-foundry/ai-platform-docs (see CODEOWNERS).
# Its .tf files use intentional non-standard HCL formatting that must not be changed.
# Skipped by infrastructure/infrastructure-setup-terraform/scripts/validate.sh.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: This set of templates demonstrates how to set up Azure AI Foundry in the basic configuration with public network setup and Microsoft-managed storage resources using AzureRM provider.
description: This set of templates demonstrates how to set up Microsoft Foundry in the basic configuration with public network setup and Microsoft-managed storage resources using AzureRM provider.
page_type: sample
products:
- azure
Expand All @@ -9,11 +9,11 @@ languages:
- hcl
---

# Azure AI Foundry: Basic setup with public networking (AzureRM)
# Microsoft Foundry: Basic setup with public networking (AzureRM)

## Key Information

This infrastructure-as-code (IaC) solution deploys Azure AI Foundry with public networking and uses Microsoft-managed storage for file upload experience. It supports getting started scenarios, for typically non-enterprise scenarios. This variant shows AzureRM Terraform provider.
This infrastructure-as-code (IaC) solution deploys Microsoft Foundry with public networking and uses Microsoft-managed storage for file upload experience. It supports getting started scenarios, for typically non-enterprise scenarios. This variant shows AzureRM Terraform provider.

## Prerequisites

Expand Down Expand Up @@ -99,5 +99,5 @@ code/

## References

- [Learn more about Azure AI Foundry architecture](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/architecture)
- [Azure AI Foundry reference docs for Terraform](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/create-resource-terraform)
- [Learn more about Microsoft Foundry architecture](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/architecture)
- [Microsoft Foundry reference docs for Terraform](https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/create-resource-terraform)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
location = "eastus"
location = "eastus2"
102 changes: 0 additions & 102 deletions infrastructure/infrastructure-setup-terraform/00-basic/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
location = "eastus"
location = "eastus2"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "random_string" "unique" {
##
resource "azapi_resource" "rg" {
type = "Microsoft.Resources/resourceGroups@2021-04-01"
name = "rg-aifoundry-${random_string.unique.result}"
name = "tf-319-basic"
location = var.location
}

Expand Down Expand Up @@ -63,7 +63,7 @@ resource "azapi_resource" "aifoundry_deployment_gpt_4o" {

body = {
sku = {
name = "GlobalStandard"
name = "Standard"
capacity = 1
}
properties = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This directory contains standalone Terraform snippet files, not a complete module.
# Each .tf file declares its own terraform{} and provider blocks and is meant to be
# copied into an existing Terraform configuration, not run directly.
# Skipped by infrastructure/infrastructure-setup-terraform/scripts/validate.sh.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Connections Terraform Examples

Connections enable your AI applications to access tools and objects managed elsewhere in or outside of Azure.

This folder provides Terraform examples for the most common connection categories:

- **AI Search**: Connect to Azure AI Search (Cognitive Search) services
- **Key Vault**: Securely access secrets and keys
- **Application Insights**: Enable monitoring and telemetry
- **Azure OpenAI**: Connect to Azure OpenAI endpoints
- **Storage Account**: Access Azure Storage for data
- **Cosmos DB**: Connect to Cosmos DB databases
- **Bing Grounding**: Enable Bing Search for grounding

## Usage

Each file demonstrates how to create a specific connection type using Terraform with the AzAPI provider. These are example snippets that you can integrate into your own Terraform configurations.

## Prerequisites

- An existing Microsoft Foundry account
- The target resource you want to connect (e.g., AI Search service, Key Vault, etc.)
- Appropriate permissions to create connections

## Important Notes

- Uses AzAPI provider for connection resources (not yet in Az
ureRM)
- Some connections require API keys or managed identity configuration
- Role assignments may be needed for managed identity auth

## Documentation

- [Microsoft Foundry connections](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/connections)
- [AzAPI Provider](https://registry.terraform.io/providers/azure/azapi/latest/docs)

`Tags: Microsoft.CognitiveServices/accounts/connections, Integration`
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Example: Azure AI Search Connection
# This example shows how to create a connection from AI Foundry to Azure AI Search

terraform {
required_providers {
azapi = {
source = "azure/azapi"
version = "~> 2.5"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.37"
}
}
}

provider "azapi" {}
provider "azurerm" {
features {}
}

variable "ai_foundry_name" {
description = "Name of your existing AI Foundry account"
type = string
}

variable "resource_group_name" {
description = "Resource group containing AI Foundry account"
type = string
}

variable "location" {
description = "Azure region"
type = string
default = "westus"
}

variable "create_new_search" {
description = "Create new AI Search service or use existing"
type = bool
default = true
}

variable "search_service_name" {
description = "Name of the AI Search service"
type = string
}

# Reference existing AI Foundry account
data "azurerm_resource_group" "rg" {
name = var.resource_group_name
}

data "azapi_resource" "ai_foundry" {
type = "Microsoft.CognitiveServices/accounts@2025-04-01-preview"
name = var.ai_foundry_name
parent_id = data.azurerm_resource_group.rg.id
}

# Conditionally create new AI Search service
resource "azurerm_search_service" "search" {
count = var.create_new_search ? 1 : 0
name = var.search_service_name
resource_group_name = var.resource_group_name
location = var.location
sku = "basic"
}

# Reference existing AI Search service
data "azurerm_search_service" "existing" {
count = var.create_new_search ? 0 : 1
name = var.search_service_name
resource_group_name = var.resource_group_name
}

locals {
search_endpoint = var.create_new_search ? "https://${azurerm_search_service.search[0].name}.search.windows.net" : "https://${data.azurerm_search_service.existing[0].name}.search.windows.net"
search_id = var.create_new_search ? azurerm_search_service.search[0].id : data.azurerm_search_service.existing[0].id
search_primary_key = var.create_new_search ? azurerm_search_service.search[0].primary_key : data.azurerm_search_service.existing[0].primary_key
}

# Create AI Search connection
resource "azapi_resource" "ai_search_connection" {
type = "Microsoft.CognitiveServices/accounts/connections@2025-04-01-preview"
name = "${var.ai_foundry_name}-aisearch"
parent_id = data.azapi_resource.ai_foundry.id

body = {
properties = {
category = "CognitiveSearch"
target = local.search_endpoint
authType = "ApiKey"
isSharedToAll = true
credentials = {
key = local.search_primary_key
}
metadata = {
ApiType = "Azure"
ResourceId = local.search_id
location = var.location
}
}
}
}

output "connection_id" {
value = azapi_resource.ai_search_connection.id
}
Loading
Loading