I am trying to use python and connect my azure ai foundry project using TypeError: AIProjectClient.__init__() missing 3 required positional arguments: 'subscription_id', 'resource_group_name', and 'project_name'

EV CV 0 Reputation points
2025-05-21T17:08:31.78+00:00

I am trying to use python and connect my azure ai foundry project using TypeError: AIProjectClient.init() missing 3 required positional arguments: 'subscription_id', 'resource_group_name', and 'project_name'

   https://microsoft.github.io/build-your-first-agent-with-azure-ai-agent-service-workshop/getting-started/#project-connection-string   I am having issues with connection string
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,572 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ravada Shivaprasad 535 Reputation points Microsoft External Staff Moderator
    2025-05-27T00:21:48.1433333+00:00

    Hi EV CV

    The error you are encountering occurs because the AIProjectClient.init() method requires three mandatory parameters: subscription_id, resource_group_name, and project_name. To resolve this issue, ensure you provide these parameters when initializing the client in your Python code. First, verify that you are using the correct subscription ID, which can be retrieved using the Azure CLI command az account show --query id --output tsv. Additionally, confirm that your resource group name matches the one used in your Azure AI Foundry deployment by listing available resource groups using az group list --query "[].name" --output tsv. Lastly, make sure that the project name is correctly configured in Azure AI Foundry.

    When initializing AIProjectClient, you should provide all necessary parameters along with proper authentication using DefaultAzureCredential. Below is an example of a properly structured initialization:

    from azure.ai.foundry import AIProjectClient 
    from azure.identity import DefaultAzureCredential 
    credential = DefaultAzureCredential()
    client = AIProjectClient.init( credential=credential, subscription_id="your-subscription-                  id", resource_group_name="your-resource-group", project_name="your-project-name")
    
    

    This approach ensures secure authentication and proper connection to your Azure AI Foundry project. For further details on configuring the connection string, you can refer to the official Microsoft documentation: Configure Project Connection. Additionally, if you are facing persistent issues, you may find relevant troubleshooting discussions in the Azure SDK for Python GitHub repository

    Thanks


Your answer

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