Why is Azure's naming convention a nightmare for Terraform?

Sam46 Advanced 1h ago 311 views 11 likes 2 min read

I've been trying to automate the plumbing for a LangChain agent, and I've hit a wall with the Microsoft Foundry setup. The goal was simple: provision a Foundry hub and a GPT-4o deployment via code so I don't have to click around the portal like it's 2010. Instead, I spent my morning staring at documentation that feels like it was written in riddles.

I managed to get the hub and project standing, but the actual model deployment is where things fall apart. If you've ever tried to "wire up" an LLM in Azure via Terraform, you know the pain of wondering whether you need a specific azurerm resource or if you have to resort to azapi because the official provider is lagging behind the actual API.

Here is the broken state of my config:

provider "azurerm" {
  features {}
}

resource "azurerm_ai_foundry" "hub" {
  name                = "my-foundry-hub"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
}

resource "azurerm_ai_foundry_project" "project" {
  name              = "my-foundry-project"
  location          = azurerm_ai_foundry.hub.location
  ai_services_hub_id = azurerm_ai_foundry.hub.id
}

# This is where the magic stops and the frustration begins
# I'm missing the actual GPT-4o deployment block

The real headache is that I can't figure out if the deployment resource itself exposes the endpoint or if there's some hidden "connection" resource I'm missing to make this callable from an external AI workflow. I'm basically trying to build a production-ready deployment from scratch, but I feel like I'm guessing.

If you've actually succeeded in doing a deep dive into this, I have two specific questions:

1. Which resource block actually works for GPT-4o? Is azurerm_cognitive_deployment the move here, or is that too legacy for the new Foundry Hub structure?
2. Does the deployment automatically create the endpoint, or am I supposed to be hunting for a separate resource to get the API key and URL for my LangChain agent?

I'm hoping for a practical tutorial or even just a snippet that doesn't result in a ResourceNotFound error. If anyone has a working deployment pattern that doesn't involve praying to the Azure gods, please share.

Help Wanted

All Replies (3)

P
PatFounder Advanced 1h ago
Did you run into any specific issues with the resource group naming constraints too?
0 Reply
J
Jamie67 Novice 56m ago
Check if the global uniqueness requirement for the hub name is what's tripping you up.
0 Reply
M
Morgan42 Novice 54m ago
Try using a random suffix in your variables to dodge those annoying naming collisions.
0 Reply

Write a Reply

Markdown supported