Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Hosted agent on your own AKS cluster is currently in preview. See the Supplemental Terms of Use for Microsoft Azure Previews for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
In this quickstart, you provision Microsoft Foundry with a prepared customer-managed AKS environment, deploy the sample hosted agent, invoke it through Foundry, and inspect the workload and logs.
Prerequisites
- Complete Prerequisites and AKS requirements (preview).
- For an existing enterprise environment, complete Architecture and resources.
- Sign in to Azure CLI and Azure Developer CLI with identities from the same Microsoft Entra tenant.
- Clone the sample repository. Run all commands from the sample repository root.
- Select the
azdenvironment that you created during prerequisite setup.
This quickstart provisions Foundry resources and deploys the prepared sample. Azure charges apply.
Provision Foundry and connect it to AKS
Choose one of the following provisioning methods. The Azure portal method is
an alternative to azd provision; don't complete both methods.
In the Azure portal, start creating a Foundry resource in the prepared subscription, resource group, and region.
Under Agent hosting (Preview), select Connected AKS cluster (preview).
Select the existing eligible AKS Cluster.
Select or create Session snapshot storage, and then select its Storage managed identity. Agent workloads use this separate workload identity to access session-snapshot storage.
On Identity, for Identity type, select User assigned. Then select the separate hosting user-assigned managed identity that has the required AKS permissions.
Note
Foundry Agent Management uses the management identity to:
- Read AKS metadata and validate the hosting configuration.
- Install, upgrade, and remove the Foundry Kubernetes extension and the runtime components delivered through it.
- Create federated identity credentials on the separate workload managed identity.
- Perform ongoing health checks, reconciliation, and cleanup for the hosting integration.
This management identity is distinct from the workload or storage managed identity that agent workloads use for session snapshots. Foundry uses the management identity for its hosting control path. You remain responsible for the AKS cluster and supporting customer resources.
Select Review + create, review the configuration, and then select Create.
Before you deploy, ensure that the resource contains an existing Foundry project and the model deployment and container registry connection declared by the sample. For detailed manual setup, see Manually prepare resources for hosted agents on your AKS cluster.
From the cloned sample repository, target the existing project:
azd ai project add --project-id "<foundry-project-resource-id>"
In the project service in azure.yaml, remove the agentHosting block because
the Azure portal already configured the AKS hosting connection.
Deploy and test the sample agent on Foundry
The cloned repository is ready to deploy. From the repository root, build and deploy the sample container:
azd deploy
Check the hosted-agent status:
azd ai agent show --output json
Continue only when the JSON output includes instance_identity.principal_id.
Grant model access
Copy instance_identity.principal_id from the JSON output. Use the agent
instance identity, not the hosting management identity or the workload
identity used for session snapshots.
The Agents extension doesn't automatically assign the Cognitive Services OpenAI User role.
Replace <agent-instance-principal-id> with the principal ID you copied.
For <model-hosting-foundry-account-resource-id>, use the resource ID of
the Foundry account that hosts the sample's model, not the project resource
ID or the endpoint URL. If AZURE_OPENAI_ENDPOINT points to another Foundry
account, use that account's resource ID.
Have an authorized administrator run the command for their shell.
PowerShell
az role assignment create `
--assignee-object-id "<agent-instance-principal-id>" `
--assignee-principal-type ServicePrincipal `
--role "Cognitive Services OpenAI User" `
--scope "<model-hosting-foundry-account-resource-id>"
Bash
az role assignment create \
--assignee-object-id "<agent-instance-principal-id>" \
--assignee-principal-type ServicePrincipal \
--role "Cognitive Services OpenAI User" \
--scope "<model-hosting-foundry-account-resource-id>"
The returned assignment should identify the agent instance principal, the Cognitive Services OpenAI User role, and the model-hosting Foundry account scope.
Check agent readiness
Run the agent diagnostics:
azd ai agent doctor
Continue when the agent version is active and diagnostics show no blocking failures.
Diagnostics don't test model invocation.
Invoke the sample agent
Invoke the deployed sample through Foundry to start a remote conversation:
azd ai agent invoke --new-session "Remember the test word ORCHID. Reply with a brief acknowledgment."
The response should briefly acknowledge the request.
Ask the agent to recall the test word:
azd ai agent invoke "What test word did I ask you to remember?"
The response should include ORCHID. This result confirms that the deployed
sample is running and that the Foundry session preserved the conversation
context. Save the session ID from the command output.
If model authorization fails, confirm that the role assignment uses the agent instance principal and the model-hosting Foundry account scope. Allow time for the assignment to propagate, then retry the invocation.
Optionally validate the AKS workload
Get cluster credentials in a dedicated kubeconfig. Use the resource group and
cluster name from AKS_RESOURCE_ID.
PowerShell
New-Item -ItemType Directory -Path .azure -Force | Out-Null
$env:KUBECONFIG = Join-Path $PWD.Path '.azure/quickstart-kubeconfig'
az aks get-credentials `
--subscription "<subscription-id>" `
--resource-group "<aks-resource-group>" `
--name "<aks-name>" `
--file $env:KUBECONFIG
kubelogin convert-kubeconfig -l azurecli
kubectl get namespaces
kubectl get pods --all-namespaces
Bash
mkdir -p .azure
export KUBECONFIG="$PWD/.azure/quickstart-kubeconfig"
az aks get-credentials \
--subscription "<subscription-id>" \
--resource-group "<aks-resource-group>" \
--name "<aks-name>" \
--file "$KUBECONFIG"
kubelogin convert-kubeconfig -l azurecli
kubectl get namespaces
kubectl get pods --all-namespaces
Look for foundry-system and the project namespace. Use read-only commands;
Foundry manages these resources.
View initial logs
Use the session ID from the remote invocation.
azd ai agent monitor --session-id "<session-id>" --type system --tail 100
azd ai agent monitor --session-id "<session-id>" --type console --tail 100
Confirm that the logs show the tested request and a successful response. Initial OpenTelemetry exporter warnings don't necessarily mean the invocation failed. Verify the response status, and check telemetry separately.
Clean up resources
This quickstart creates billable Azure resources. Remove the test environment when you no longer need it by following your organization's approved resource-deletion process.
Next steps
- Review Feature availability and limitations.
- Learn how to Operate hosted agents on AKS.
- If a step fails, see Troubleshoot bring your own AKS.