Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform
Hello saurabh pophare,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are in need of how you can deploy an AI Agent created in Microsoft AI Foundry to a website for public access.
The safest architecture is browser > your backend > Azure AI Foundry Agent Service so you never expose tokens in the client. Microsoft’s reference implementations follow this proxy pattern and show how threads and agents are orchestrated from a server‑side app (Container Apps/App Service) with observability and streaming support (see the hosted agents and sample web app guidance) and hosted agents concepts (CORS/streaming), and this is a reference sample on proxy, Container Apps.
The first decision is how the backend authenticates in a non‑interactive environment. Prefer Managed Identity when hosting on Azure App Service or Container Apps, it’s secretless, policy‑friendly, and designed for servers. If you cannot use managed identity (e.g., off‑Azure), use ClientCertificateCredential to avoid secrets while remaining compliant; ClientSecretCredential is a last resort when policy allows. These credential types are part of Azure Identity, with clear guidance on configuration across languages.Chech this links for detains on secretless -https://learn.microsoft.com/en-us/dotnet/api/azure.identity.managedidentitycredential; Python variant – https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.managedidentitycredential; ClientCertificateCredential – https://learn.microsoft.com/en-us/dotnet/api/azure.identity.clientcertificatecredential; ClientSecretCredential – https://learn.microsoft.com/en-us/dotnet/api/azure.identity.clientsecretcredential
Authentication alone won’t grant access: you must assign data‑plane RBAC roles on the Foundry project and any underlying AI services your agent uses (Azure OpenAI, Content Safety, AI Search). Microsoft’s control‑plane vs data‑plane model requires the identity to have dataActions permissions to invoke models/agents. Typical minimums include Azure AI User at the Foundry project scope and, if using Azure OpenAI, Cognitive Services OpenAI User/Contributor; failing these yields “access denied” even with valid tokens.\ References: Foundry auth & authorization (control/data plane) – https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/authentication-authorization-foundry; Foundry RBAC (project roles) – https://video2.skills-academy.com/en-us/azure/ai-foundry/concepts/rbac-azure-ai-foundry?pivots=fdp-project; Azure OpenAI RBAC (roles & dataActions) – https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/role-based-access-control
Implementation is straightforward: expose a POST /chat endpoint in your backend, acquire a token with your chosen credential, then call the Agents API using your agent_id (and the thread_id to continue a conversation). Return the model’s response and persist the thread for continuity. Here’s a minimal Python/Flask sketch using Managed Identity (swap in ClientCertificateCredential or ClientSecretCredential as needed), and the Azure AI Agents SDK for message relay:
# Flask backend (Python 3.10+)
from flask import Flask, request, jsonify
from azure.identity import ManagedIdentityCredential
from azure.ai.agents import AgentsClient # see SDK README for exact imports
import os
app = Flask(name)
# Environment: set AGENTSENDPOINT, PROJECTID, AGENTID
endpoint = os.getenv("AGENTSENDPOINT") # e.g., https://<foundry-endpoint>
projectid = os.getenv("PROJECTID")
agentid = os.getenv("AGENTID")
# Secretless auth on Azure
credential = ManagedIdentityCredential()
client = AgentsClient(endpoint=endpoint, credential=credential, project=projectid)
@app.post("/chat")
def chat():
payload = request.getjson()
usermsg = payload.get("message", "")
threadid = payload.get("threadid") # optional
# create thread if first interaction
if not threadid:
thread = client.createthread()
threadid = thread.id
# send message and run agent
client.createmessage(threadid=threadid, role="user", content=usermsg)
result = client.run(agentid=agentid, threadid=threadid) # blocking run; consider streaming
return jsonify({"threadid": threadid, "reply": result.output_text})
For gents SDK (usage patterns) – https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-agents/README.md; Managed Identity on App Service/Container Apps – deployment example – https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/deploy-your-first-azure-ai-agent-service-powered-app-on-azure-app-service/4396173
For hosting, deploy to Azure App Service or Container Apps, enable Managed Identity (Track A), wire environment variables, and configure HTTPS, CORS, and rate limiting at the backend. Microsoft’s end‑to‑end blog shows IAM role assignment, managed identity enablement, and a clean Git‑based App Service deployment; the Azure‑Samples repo demonstrates Container Apps with tracing and diagnostics. Keep tokens server‑side and never expose agent endpoints directly to browsers. For an App Service + Agent Service end‑to‑end – https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/deploy-your-first-azure-ai-agent-service-powered-app-on-azure-app-service/4396173; Sample “get‑started‑with‑ai‑agents” (Container Apps, proxy, monitoring) – https://github.com/Azure-Samples/get-started-with-ai-agents; Hosted agents (CORS/streaming/SSE) – https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents
Finally, validate end‑to‑end: confirm token acquisition (Managed Identity/Certificate/Secret), verify RBAC grants at project/service scopes, and exercise the /chat endpoint with realistic prompts to ensure threads persist and agent responses stream correctly. If you encounter access errors, re‑check data‑plane roles and scope (subscription/resource group/project). This summarized plan resolves the original deployment challenge, addresses the “no secrets allowed” constraint, and aligns with Microsoft’s recommended production posture.\ References: Foundry auth/RBAC least‑privilege guidance – https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/authentication-authorization-foundry; Foundry RBAC (built‑in roles & effects on UI/dataActions) – https://video2.skills-academy.com/en-us/azure/ai-foundry/concepts/rbac-azure-ai-foundry?pivots=fdp-project; Azure OpenAI RBAC specifics – https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/role-based-access-control
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.