Quickstart: Create your first agent by enabling ESAF Agent Chat¶
In this quickstart, you switch on ESAF Agent Chat for a project and ask it a first question. ESAF Agent Chat is a Microsoft Foundry agent with a private web chat and live voice. It answers questions about your Factory from your own documentation and code.
Tip
Run it guided. The ESAF Tutorial Guide types the project calls for you and checks every step: open an ESAF tutorial and the track Scenarios 1-3. Download the ESAF Tutorial Guide. It's a private preview: ask Joakim Åström on LinkedIn for a preview code. The guide has no Agent Chat lab yet.
sequenceDiagram
participant You
participant API as Factory API
participant Run as Project pipeline
participant Chat as Agent Chat app
You->>API: upsert project with the four settings
API->>Run: start the project run
Run->>Chat: create the Foundry agent, then deploy the chat app
You->>Chat: sign in and ask a question
Prerequisites¶
- A project in Dev from Quickstart: Add a project for your team, or project 001 from Quickstart: Create your AI Factory. Any project number works. The examples use project 001 on scale set 001.
- On that project:
enableAIFoundry,enableAISearchandenableContainerAppsset to"true". - Private or hybrid networking, so that the project's Container Apps environment is internal. A Factory with public networking can't run Agent Chat. See hub and network modes.
- A chat model deployment that succeeded. The project setting
modelGPTXNamenames it. - A text-embedding deployment that succeeded, for example
text-embedding-3-large. - A Microsoft Entra admin who can create an app registration.
- The Entra object IDs of the people who may use the chat. They get read-only access.
- VPN or another route into the project's private network.
Important
The chat app deploys in Dev only. Runs for Stage and Prod skip it.
Create the sign-in registration¶
An Entra admin does this once per project. Pipelines never write to Microsoft Entra. The commands in this section are PowerShell and need Python 3.12. In Bash, end a continued line with a backslash instead of a backtick.
- Find the address your chat app gets. The app name is
aifactory-agent-project<NNN>-dev:
az containerapp env list --resource-group <project resource group> `
--query "[0].properties.defaultDomain" --output tsv
- From the root of your consumer repository, go to the agent folder and install what the tool needs in its own virtual environment. Do this once per computer:
Set-Location .\azure-enterprise-scale-ml\usecase_code\40-agent-factory\40-aifactory-agent
py -3.12 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.lock.txt
.\.venv\Scripts\python.exe -m pip install -e ..\..\..\environment_setup\azurefactory-cli
- Copy
config.example.jsonin that folder tomy-agent.jsonand put your own object ID underauth.grants. - Plan the registration. Add
--applywhen the plan looks right:
.\.venv\Scripts\python.exe -m aifactory_agent.browser_auth --config ./my-agent.json `
--redirect-uri "https://aifactory-agent-project001-dev.<default domain>/" `
--user-object-id "<your Entra object ID>"
- Copy
client_idfrom the output. You need it in the next step.
Each project gets its own registration. Its name comes from the address, for example
Enterprise Scale AI Factory Agent (aifactory-agent-project001-dev.<first part of the default domain>), so
other Factories and projects in your tenant keep theirs. The output shows the name as display_name. To pick
another name, add --display-name "<name>", and use the same option every time you run the tool again.
The tool gives sign-in access to you only. Ask your Entra admin to assign the other readers to the enterprise
application with the name in display_name. For the details, see
authentication in the agent guide.
Turn on the four settings¶
Agent Chat is an update of your project, so it's scenario 3 with four settings. The call saves the settings and then deploys them.
| Setting | What it does |
|---|---|
enableFactoryChatAgent |
Creates the Foundry prompt agent enterprise-scale-ai-factory. |
enableAIFactoryAgentLiveVoice |
Deploys the chat web app with live voice. Needs enableFactoryChatAgent. |
aifactoryAgentEntraAppId |
Sets the client ID of the sign-in registration. |
aifactoryAgentReaderObjectIds |
Lists 1 to 20 object IDs, comma-separated, that get read-only access. |
More settings
| Setting | What it does |
|---|---|
aifactoryAgentContainerAppsEnvironment |
Names the internal environment. Empty picks the only one in the project resource group. |
aifactoryAgentModelDeployment |
Names the agent's own model deployment. Empty uses modelGPTXName. |
aifactoryAgentVoiceName |
Sets the voice. Empty uses en-US-Ava:DragonHDLatestNeural. |
aifactoryAgentVoiceLanguages |
Lists the input languages. Empty uses en-US; Swedish needs sv-SE,en-US. |
aifactoryAgentConfigFile |
Points to your own agent configuration file in your repository. It's merged over the generated one. |
aifactoryAgentFactoryId |
Sets the registered catalog factory ID for chat usage events (aifactory.chat, My Project Usage & outcomes). Empty sends no events. |
aifactoryAgentScaleSetId |
Sets the registered catalog scale set ID for chat usage events. Set it together with aifactoryAgentFactoryId. |
Deploy Agent Chat from the Azure portal¶
This preview button runs the deployment, rather than opening this guide. After you select Review + create and Create, Azure runs the existing Agent Chat deployers on a prepared private Linux VM. They create the Foundry agent, build its knowledge index and deploy the private chat app with live voice. This is an existing-project route, not a new Factory bootstrap. The blue infrastructure-only button does not supply the models, sign-in registration or prepared runner required here.
Prepare the runner once¶
Use a running Linux VM with the Azure VM agent and private DNS/routing to the project's Foundry, Search,
Storage and Container Apps endpoints. It also needs outbound access to the approved Python package feed
for the locked application dependencies and Linux wheels. Azure CLI, Bicep, Python 3.12 or newer with
venv support, and Bash must already be installed. A project DSVM is not automatically a prepared runner.
Keep a dedicated, persistent consumer checkout on that VM, including its accelerator submodule and the
project's own variables.json. Do not point this deployment at a temporary ADO/GHA _work checkout:
another pipeline can clean or replace it. The operator maintains the checkout and reviews its source;
the button does not clone repositories, fetch a new revision, ask for Git credentials or overwrite configuration.
Update the accelerator to a revision with the automatic VM identity support in bootstrap/lib/agent_chat_portal.py
before using this form. An older prepared checkout still requires explicit advanced values.
Prepare a separate operator environment in that checkout (replace the path with your actual location):
cd /opt/esaf/consumer
python3 -m venv .venv-agent-operator
.venv-agent-operator/bin/python -m pip install \
-r azure-enterprise-scale-ml/usecase_code/40-agent-factory/requirements.txt
The live-voice deployer prepares its own application environment; do not mix it with the operator environment. Allow free disk space for an isolated copy of the accelerator source, application environment and downloaded wheels. The runner removes its temporary source, build files and Azure CLI credentials when the command exits normally. The four settings above, model deployments and Entra registration must be ready in the selected project's configuration.
An administrator must authorize an attached managed identity to deploy into the target Dev project. It can be user-assigned or the VM's system-assigned identity. It needs Contributor and User Access Administrator on the project resource group, plus read access to the subscription and any referenced common resources. The shared build runner's default common-resource-group identity is not automatically authorized for this. The existing deployers create application identities and resource-scoped role assignments, including their own Foundry/Search/Storage data roles. The portal entry itself neither grants the runner permissions nor creates an Entra application registration.
The person selecting Create also needs permission to deploy ARM templates in the runner's resource group and run commands on that VM, for example Virtual Machine Contributor. Run Command executes with administrator privileges on the VM; keep that permission and the maintained checkout restricted to trusted operators.
Fill in the deployment¶
Select your Deployment VM (existing Linux runner) and Dev project number (default 001).
The form uses the VM's resource group automatically. Normally leave Advanced settings unchanged.
| Setting | Automatic value and when to override |
|---|---|
| VM region | Read from the selected VM, even if its resource group's region differs. No field to fill in. |
Factory project folder on VM (consumerRoot) |
/opt/esaf/consumer. This is the existing repository folder on the VM, containing azurefactory/ or aifactory/ and azure-enterprise-scale-ml/; it is not a folder on your PC. Override only if the administrator prepared it elsewhere. |
Prepared Python on VM (pythonExecutable) |
<Factory project folder>/.venv-agent-operator/bin/python. This is the Python executable inside the prepared operator environment, not the environment's folder. Override only for another prepared installation. |
VM identity override (managedIdentityClientId) |
The VM's sole user-assigned identity; if none exists, its system identity. With multiple user-assigned identities, specify an attached client ID; enter system to select the system identity explicitly. |
Project subscription override (projectSubscriptionId) |
dev_sub_id from the selected project's variables.json. An override must match that configuration and the current tenant. |
Project settings file override (configurationPath) |
The matching project's variables.json. Set a path only when lookup is ambiguous or you use another configuration location. |
Azure knows the VM's region and attached identity IDs, but cannot discover arbitrary folders or Python environments inside its operating system. The two path defaults follow the preparation example above; they do not scan the VM, clone a repository or install missing packages. A missing default path gives a specific error instead of choosing another checkout. Automatic identity selection checks attachment, not project authorization: the selected identity still needs the permissions described above. Multiple identities are never tried one after another.
The ARM parameter names remain available for scripts. runnerVmName is the only required template parameter;
projectNumber defaults to 001, the optional overrides default to empty, and runId is generated for each new
deployment. A direct ARM caller can still override runnerLocation, but normally leaves it empty.
Warning
Selecting Create changes Azure and incurs application, model and embedding charges. Do not run this deployment and a project pipeline concurrently. Azure CLI authentication is isolated from other VM sessions.
Azure waits for the deployment script to finish, with a four-hour limit. A skipped stage, a failed deployer
or a failed private /health/ready check fails the deployment instead of reporting a successful chat.
The Run Command instance view shows the result and application URL; its captured output is limited to the
last 4 KB. Read runCommandResourceId in the deployment outputs to find the command.
After deployment, sign in from an authorized browser and try a question and live voice.
For a failed run, fix the reported prerequisite and reopen the button for a new run; a new runId is generated.
When using ARM directly or redeploying stored parameters, change runId. There is no automatic rollback
of Azure resources already created. No live Azure deployment is asserted by this template's offline coverage.
For the implementation, see the portal template and
Microsoft's managed Run Command documentation.
Maintainers regenerate the published template with
bicep build portal/agent-chat/main.bicep --outfile portal/agent-chat/azuredeploy.json.
Deploy with the app, CLI, SDK or REST¶
- In the app, open the menu and select Configuration wizard > Quick setup & tear down.
- Select 3. Add or update project, and enter your project: Environment
dev, Project number001and Project scale set001. - In Optional settings JSON, enter the four settings, as in the
agent-chat.jsonfile on the CLI tabs. - Tick I approve this scenario: it runs at once and changes Azure., then select Run selected scenario.
The same settings are checkboxes and fields under AI Factory Agent chat & live voice, on the Simple Mode page and in the Configuration wizard.
@{
enableFactoryChatAgent = 'true'
enableAIFactoryAgentLiveVoice = 'true'
aifactoryAgentEntraAppId = '<client ID>'
aifactoryAgentReaderObjectIds = '<object ID 1>,<object ID 2>'
} | ConvertTo-Json | Set-Content .\agent-chat.json
azurefactory esaf upsert-project 001 dev --scale-set 001 --settings-json .\agent-chat.json --wait
cat > agent-chat.json <<'JSON'
{
"enableFactoryChatAgent": "true",
"enableAIFactoryAgentLiveVoice": "true",
"aifactoryAgentEntraAppId": "<client ID>",
"aifactoryAgentReaderObjectIds": "<object ID 1>,<object ID 2>"
}
JSON
azurefactory esaf upsert-project 001 dev --scale-set 001 --settings-json ./agent-chat.json --wait
from azurefactory import esaf
job = esaf.upsert_project("001", "dev", scale_set="001", settings={
"enableFactoryChatAgent": "true",
"enableAIFactoryAgentLiveVoice": "true",
"aifactoryAgentEntraAppId": "<client ID>",
"aifactoryAgentReaderObjectIds": "<object ID 1>,<object ID 2>",
})
print(job.wait()["status"])
In Bash, with API_URL, API_KEY and FOLDER set as in
Quickstart: Create your AI Factory:
jq -n --arg folder "$FOLDER" '{folder: $folder, approved: true, project: "001", environment: "dev",
scale_set: "001",
settings: {enableFactoryChatAgent: "true", enableAIFactoryAgentLiveVoice: "true",
aifactoryAgentEntraAppId: "<client ID>", aifactoryAgentReaderObjectIds: "<object ID 1>,<object ID 2>"}}' |
curl --silent --show-error --fail-with-body -X POST "$API_URL/api/v1/esaf/upsert-project" \
--header "X-API-Key: $API_KEY" --header 'Content-Type: application/json' --data @-
Allow about an hour for the first run: the project run, plus about 30 minutes to build the knowledge index. Later runs are faster.
You can also deploy only the agent from a terminal, without a full project run. From your consumer
repository root, ./GHA-azurefactory.sh add-aifactory-agent-chat --to-project 001 shows the plan, and
--apply deploys. ADO-azurefactory.sh takes the same options.
Connect to the private network¶
The chat app is internal, so you reach it through your Factory's VPN gateway. You sign in to the VPN with Microsoft. Do this once per computer and Factory.
- Install Azure VPN Client:
winget install --id 9NP355QT2SQB --source msstore --accept-package-agreements --accept-source-agreements
- Download your Factory's VPN profile. The gateway is in the common resource group:
$sub = '<your Dev subscription ID>'; $rg = '<common resource group>'
$gateway = az network vnet-gateway list --subscription $sub --resource-group $rg --query "[0].name" --output tsv
$url = az network vnet-gateway vpn-client generate --subscription $sub --resource-group $rg --name $gateway `
--processor-architecture Amd64 --output tsv
Invoke-WebRequest $url -OutFile "$HOME\Downloads\esaf-vpn-profile.zip"
Expand-Archive "$HOME\Downloads\esaf-vpn-profile.zip" "$HOME\Downloads\esaf-vpn-profile" -Force
The profile is esaf-vpn-profile\AzureVPN\azurevpnconfig.xml in your Downloads folder. It stays out of
your Factory repository.
- Open Azure VPN Client, select + > Import, open
azurevpnconfig.xml, and select Save. - Select Connect and sign in with Microsoft. First disconnect any other VPN that uses the same client address range.
The profile sets your Factory's DNS resolver, so the chat address resolves to its private IP.
Ask your first question¶
- Connect your VPN, as in Connect to the private network.
- Get the chat address:
az containerapp show --name aifactory-agent-project001-dev --resource-group <project resource group> `
--query properties.configuration.ingress.fqdn --output tsv
- Open
https://<that address>/in Edge, Chrome, Safari or Firefox, and sign in with Microsoft. - Ask: "What is the health of my AI Factory, and which skills can I use?"
You get a written answer with source citations. To talk instead, select Start talking and allow the microphone.
Verify the result¶
The job ends with status succeeded, and the orb in the chat shows what the agent is doing:
| Listening | Thinking | Speaking |
|---|---|---|
![]() |
![]() |
![]() |
If something goes wrong:
| Symptom | Fix |
|---|---|
| The run fails on the live voice step | Check the prerequisites: the agent, both model deployments and an internal Container Apps environment must exist. |
| Voice is on but the chat agent isn't | Set enableFactoryChatAgent to "true" too. Voice alone fails with a clear message. |
| A reader can't sign in | Assign that person to the enterprise application in Microsoft Entra. |
| Voice is unavailable | Select Use typed chat. Typing still works. |
For more, see troubleshooting in guide 21.
Clean up resources¶
Set both switches to "false" and run the same call again. Later runs then skip Agent Chat. This doesn't
delete anything: the app, the index and the role assignments stay.
To remove them, follow teardown in the agent guide, or delete the whole project with Quickstart: Clean up.
Next step¶
Back: Quickstart: Add a project for your team
Next: Quickstart: Clean up
Related:
- Guide 21: Agent Factory chat and live voice: security, operations and limits.
- ESAIF Chat Agent: how the agent, the MCP and the knowledge graphs relate.
- Run your first agent in your ESAF project: the project team builds its own agent.


