Failed to find PROJECT_CONNECTION_STRING in Azure AI Foundry

桂學文 Kevin Kuei 125 信譽點數
2025-05-27T02:37:15.0633333+00:00

Hi,

I'm trying to follow the document to use Azure AI Foundry SDK client (python).

https://learn.microsoft.com/en-us/azure/ai-foundry/how-to/develop/sdk-overview?pivots=programming-language-python

(Note that the code in the document didn't mention about "conn_str")

But I got error:

TypeError: AIProjectClient.from_connection_string() missing 1 required positional argument: 'conn_str'
 

How to find the project conn_str?

Here is what I did:

  1. I've created a Foundry project (I knew there are two types of projects, the project type in this case is "Foundry project").
  2. az login successfully
  3. pip install azure-ai-projects azure-ai-identity
  4. Find my project endpoint on Azure AI Foundry portal
  5. Run the following code
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential

project_endpoint = "https://pj-kk-250526-1458-resource.services.ai.azure.com/api/projects/pj-kk-250526-1458"
credential = DefaultAzureCredential()
project_client = AIProjectClient.from_connection_string(
    credential=credential,
    #conn_str=""
    endpoint=project_endpoint
)

The error:

Traceback (most recent call last):
  File "/workspace/Azure_Agent/1_Grounding_with_Bing_Search.py", line 24, in 
Azure
Azure
雲端運算平台和基礎結構,可透過 Microsoft 管理的資料中心全球網路來建置、部署和管理應用程式與服務。
52 個問題
{count} 則投票

接受的回答
  1. Sampath 3,750 信譽點數 Microsoft 外部員工 仲裁者
    2025-05-28T06:27:11.67+00:00

    Hi @桂學文 Kevin Kuei

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to Accept the answer.

    Issue:

    While following the official Azure AI Foundry SDK client documentation (Python), the following error occurred:

    TypeError: AIProjectClient.from_connection_string() missing 1 required positional argument: 'conn_str'
    

    While attempting to initialize the AIProjectClient using an endpoint and DefaultAzureCredential, but the from_connection_string() method specifically requires the conn_str argument.

    Solution:

    The issue was resolved by upgrading the azure-ai-projects package to version 1.0.0b11.

    This version update resolved the missing argument error and allowed the SDK to properly accept the required parameters for AIProjectClient.


    Please click Accept Answer and kindly upvote it so that other people who face a similar issue may get benefitted from it.

    有 1 人認為此回答有所幫助。
    0 則留言 沒有留言

1 個其他答案

排序依據: 最實用
  1. 桂學文 Kevin Kuei 125 信譽點數
    2025-05-28T05:40:27.36+00:00

    I've solved my problem by upgrading the azure-ai-projects to version 1.0.0b11.


您的回答

問題作者可以將答案標示為「已接受的回答」,有助使用者知道此回答解決了作者的問題。