I'm having trouble connecting my Azure Function App to an AI Agent in Azure Foundry using Python. I've been following the official documentation for the Azure AI Agents client library, but things are still not working. I've been stuck for weeks, and unfortunately, I haven't had much luck with Microsoft support either. Has anyone successfully managed to connect to an AI agent from a Function App using Python? If so, what libraries did you use?
1 Answer
Have you checked your Network Settings and the Firewall Settings on your Azure AI Foundry resource? Also, can you access the logs from your Function App using the Kudu console? If you share any error logs, we might be able to help further. Besides that, double-check your authentication settings and role-based access controls (RBAC) on the AI service. You might want to look into the list of all Azure SDK Python Packages for more information on what’s available.
I'm getting this main error: type object 'AIProjectClient' has no attribute 'from_connection_string' when I try to initialize the client. The code looks like this:
```python
def _initialize_client(self):
"""Initialize the Azure AI Projects client"""
try:
self.project_client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
conn_str=self.connection_string
)
print("✅ Client initialized successfully.")
except Exception as e:
print(f"❌ Error initializing client: {e}")
raise
```
My connection string is from the project connection details. Any thoughts?