Share via

Unable to run an agent inside a python app hosted in App service. Getting "Failed to resolve model info for: None"

Raqib Rasheed 0 Reputation points
2025-11-25T10:36:36.69+00:00

I am running a python application in app service. The app calls an agent already deployed through Foundry portal. But an error is thrown stating " Failed to resolve model info for: None". A model deployment is already assigned to the agent through portal.

I am using AzureAIAgentClient class to initialize the agent and ChatAgent class to do the actual work.

async def agent_health_check():
    """Test endpoint to verify agent connectivity and managed identity authentication."""
    logger.info("Starting agent health check with managed identity.")
 
    try:
        async with ManagedIdentityCredential() as credential:
            logger.debug("Acquired ManagedIdentityCredential successfully.")
            client = AzureAIAgentClient(
                async_credential=credential,
                project_endpoint=PROJECT_ENDPOINT,
                agent_id=GENERATOR_AGENT_ID,
            )
            logger.debug("Created AzureAIAgentClient with managed identity.")
 
            async with ChatAgent(
                chat_client=client,
                instructions="You are a simple test agent. Reply briefly."
            ) as agent:
                logger.debug("Created ChatAgent, sending prompt 'hi' to agent.")
                response = await agent.run("hi")
                logger.debug("Received response from agent: %s", response.text)
 
        return {
            "status": "healthy",
            "service": "gateway",
            "version": "1.0.0",
            "agent_response": response.text,
            "message": "Managed identity authentication and agent call succeeded."
        }
    except Exception as e:
        logger.error("Agent health check failed: %s", str(e), exc_info=True)
        return {
            "status": "unhealthy",
            "service": "gateway",
            "version": "1.0.0",
            "error": str(e),
            "message": "Managed identity or agent call failed."
        }

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Jerald Felix 12,460 Reputation points Volunteer Moderator
    2025-11-28T10:24:10.1033333+00:00

    Hello Raqib Rasheed,

    Thanks for raising this question in Q&A forum.

    I understand that your AI Agent (using the Azure AI Project SDKs) works locally but fails to run when deployed to an Azure Container App (ACA).

    This issue is almost always caused by Authentication differences between your local environment and the cloud environment. Locally, the SDK uses your user credentials (via az login). In the cloud, it tries to use a Managed Identity, which requires specific setup.

    Please check the following three configurations:

    1. Enable Managed Identity:
      • Go to your Container App in the Azure Portal.
      • Select Identity > User assigned (Recommended) or System assigned.
      • Add an identity.
    2. Grant Permissions (RBAC):
      • The identity you assigned to the Container App must have permissions to access the Azure AI Project.
      • Go to your Azure AI Project (or the underlying AI Hub resource).
      • Go to Access control (IAM) > Add role assignment.
      • Assign the "Azure AI Developer" (or Cognitive Services User) role to the Managed Identity you created in Step 1.
      • Note: Without this role, the agent code will fail with 401/403 errors when trying to create threads or run messages.
    3. Update Environment Variables:
      • In your Container App Containers settings, ensure you have passed the necessary environment variables that your code expects (e.g., PROJECT_CONNECTION_STRING).
      • Critical for User-Assigned Identity: You must add an environment variable named AZURE_CLIENT_ID and set its value to the Client ID of the User Assigned Managed Identity. Without this, DefaultAzureCredential in Python may fail to select the correct identity or fallback to a failed state.

    Troubleshooting Logs:

    If the issue persists, check the Log Stream in the Container App portal. If you see an error like CredentialUnavailableError or ClientAuthenticationError, it confirms the identity setup above is incomplete.

    If helps, approve the answer.

    Best Regards,

    Jerald Felix

    Was this answer helpful?

    0 comments No comments

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.