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

Sam46 Advanced 8/11/2026 351 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)

Want a live back-and-forth? Join the global AI chat room — login to talk.

P
PatFounder Advanced 8/11/2026

This is such a mess. Did you hit those annoying resource group naming constraints too?

0 Reply
J
Jamie67 Novice 8/11/2026

Struggling with this! Is that global uniqueness requirement for the hub name causing your issues too?

0 Reply
M
Morgan42 Novice 8/11/2026

Naming collisions are the worst. Would using random suffixes in variables actually stop those Azure errors?

0 Reply

Write a Reply

Markdown supported