AI Foundry project created via Terraform is not usable from Agent Framework

Chedy Missaoui 20 Reputation points
2025-11-03T14:26:00.8733333+00:00

We created the following hierarchy of resources via terraform (as described in the Microsoft Learn):
User's image

In a C# console app, we are trying to create a persistent agent that uses the deployed model:

using Azure.Identity;
using Azure.AI.Agents.Persistent;
using Azure;
using Microsoft.Agents.AI;
// Some values are redacted
string endpoint = "https://mainaiserv*****.services.ai.azure.com/api/projects/mainaiserv****";
string deploymentName = "gtp35******";  

var client = new PersistentAgentsClient(endpoint, new DefaultAzureCredential());

Response<PersistentAgent> aiFoundryAgent = await client.Administration.CreateAgentAsync(         deploymentName, "Agent003", "A question answerer", "You are a helpful assistant that provides concise answers that do not exceed 50 words.");

Creating the agent results in a 404 project not found error:

Azure.RequestFailedException: 'The project does not exist.Status: 404 (ResourceNotFound)ErrorCode: ResourceNotFound

It seems that the deployed model is not visible via the project endpoint, furthermore deploying the agent under the project is:

  1. Not possible via azcli, terraform and ARM as all three accept a Foundry Resource as parent with no way to specify a project
    https://registry.terraform.io/providers/hashicorp/azurerm/4.51.0/docs/resources/cognitive_deployment
    https://learn.microsoft.com/en-us/cli/azure/cognitiveservices/account/deployment?view=azure-cli-latest#az-cognitiveservices-account-deployment-create
    https://learn.microsoft.com/en-us/azure/templates/microsoft.cognitiveservices/accounts/deployments?pivots=deployment-language-arm-template
  2. The Agent Section in the AI Foundry Project created via IaC seems stuck here with the drop down always empty:
    User's image
    However, everything works fine when the AI foundry resource, the underlying project and the model deployments are created from the Azure portal and AI Foundry portal.

Is this an issue with the azurerm provider ? Or are we missing something ?

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Amira Bedhiafi 41,111 Reputation points Volunteer Moderator
    2025-11-04T10:31:58.01+00:00

    Hello Chedy !

    Thank you for posting on Microsoft Learn Q&A.

    I think the project you created with Terraform isn’t the kind of Foundry Project that the Agent Service and the PersistentAgentsClient expects, and it’s missing the connection to your Azure OpenAI resource and that's explain why the agents dropdown is empty and why your call is failing.

    You can use the AzureRM provider to create the AI Foundry account and even a project but today it doesn’t cover the newer capability so you may need to use AzAPI.

    https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/create-resource-terraform

    The agents only lists an Azure OpenAI connection that’s been added to the project and is in a supported or same region so if there’s no connection the dropdown stays blank https://learn.microsoft.com/en-us/azure/ai-services/connect-services-ai-foundry-portal

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.