Creating connections programmatically between Search AI and Azure Foundry Project #102
-
Is there way to add connection to the AI Foundry Project? For a Foundry "Hub" we can use the I am yet to find a way to create a connection to my AI Search resource programmatically, either by SDK, REST API, or even terraform. If this feature doesn't exist, what is the way to do this as it's unrealistic to expect half of the workflow to be in code and the other half still waiting for manual action. If it does exist could someone point me in the correct direction? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So, YES there is a way to programmatically create connections to Azure AI Search within an AI Foundry Project. Programmatic Connection Options Python SDK via
Terraform with resource "azapi_resource" "ai_search_connection" {
type = "Microsoft.MachineLearningServices/workspaces/connections@2025-01-01-preview"
name = "my-search-connection"
parent_id = azurerm_ai_foundry_project.example.id
location = "global"
body = {
properties = {
category = "AzureAISearch"
target = var.search_endpoint
authType = "ApiKey"
isSharedToAll = true
metadata = {
ApiType = "Azure"
ResourceId = var.search_resource_id
}
credentials = {
key = var.search_api_key
}
}
}
} This approach is used in [Carlos Mendible’s Terraform walkthrough](https://carlos.mendible.com/2025/05/20/deploy-azure-foundry-and-bing-grounding-with-terraform/) and aligns with the [official Foundry connection schema](https://learn.microsoft.com/en-us/azure/ai-foundry/foundry-models/how-to/configure-project-connection). REST API How to do this
|
Beta Was this translation helpful? Give feedback.
Hi @MicroMichaelIE
So, YES there is a way to programmatically create connections to Azure AI Search within an AI Foundry Project.
Programmatic Connection Options
Python SDK via
AIProjectClient
You can use the
AIProjectClient
fromazure.ai.projects
to list and reference existing connections. However, creating new connections (e.g. to Azure AI Search) currently requires either:Terraform with
azapi_resource
You can create connections to Azure AI Search using Terraform and the
azapi_resource
block. Here's a sim…