Host an AI agent HTTP API
App Service Builder can host an HTTP assistant application that sends bounded text requests to a separately configured external model service.
At a glance
- Run the
agent-webNode 24 sample as a single-turn, tool-free assistant. - Explicitly choose an authorized OpenAI model or Azure OpenAI deployment and configure its key server-side.
- Bound input, output, concurrency, and model wait time; service failures return errors rather than simulated answers.
- Use this guide for Private Preview development/test only after your contact confirms the environment and sample are ready for you.
Prerequisites
Use your Private Preview subscription and an available region. Open the Portal or install Builder CLI. The source belongs to the AI assistant repository. See the sample catalog for choices and target-verification prerequisites.
App Service Builder hosts the HTTP application, not the model or a managed agent runtime. The sample deliberately limits agent behavior to one assistant turn without autonomous tools, conversation persistence, or background work. Its external integration uses the documented OpenAI Responses API or Azure OpenAI Responses API in Microsoft Foundry. You separately authorize service access, select a compatible model, and own charges and data-handling decisions. No model availability or production suitability is implied.
Quick start locally
Fork the sample repository to your account and clone your fork.
Run from its repository root, keeping the root builder.yaml with the application.
With Node 24:
npm ci --ignore-scripts
npm test
export APP_API_TOKEN="$(node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))")"
npm start
Use curl http://127.0.0.1:8080/health to confirm process liveness.
Tests mock the provider boundary and require no provider credential.
Model requests remain unavailable until you configure the real service; there is no fake-success fallback.
For an opt-in real request, securely supply MODEL_SERVICE=openai, your OPENAI_API_KEY, and an authorized OPENAI_MODEL in the server environment, then restart.
Choose a model supporting Responses API text input and max_output_tokens.
For Azure OpenAI in Microsoft Foundry, instead supply MODEL_SERVICE=azure-openai, AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com, the existing resource's AZURE_OPENAI_API_KEY, and AZURE_OPENAI_DEPLOYMENT set to your model deployment name.
The sample uses Azure's /openai/v1/responses endpoint; other Foundry model providers and hosted-agent runtimes are not implemented.
Do not paste keys into shell history or put them in browser code.
In another terminal with the same app token:
curl --fail-with-body http://127.0.0.1:8080/agent \
-H "Authorization: Bearer $APP_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"message":"Explain HTTP in one sentence."}'
Successful output is JSON containing a model-produced reply.
Answers are nondeterministic and need safety/quality evaluation for your use case.
Stop the server with Ctrl+C.
Request and configuration contract
| Item | Sample contract |
|---|---|
POST /agent | Authenticated JSON with only message: nonblank text up to 2000 UTF-16 code units; body up to 8192 bytes |
| Success | {"reply":"<text>"}; completed assistant text up to 4000 UTF-16 code units |
GET /health | Public status 200 with OK; process liveness, not provider readiness |
GET / | Public sample identifier |
APP_API_TOKEN | Required app bearer credential; at least 32 characters |
MODEL_SERVICE | Required value openai or azure-openai; no other provider implementation |
OPENAI_MODEL | Explicit authorized model ID; no default |
OPENAI_API_KEY | Server-side provider credential; never included in model input |
AZURE_OPENAI_ENDPOINT | Azure provider only: HTTPS https://<resource>.openai.azure.com origin without credentials, custom port, path, query, or fragment |
AZURE_OPENAI_DEPLOYMENT | Azure provider only: explicit model deployment name |
AZURE_OPENAI_API_KEY | Azure provider only: server-side resource key; never included in model input |
PUBLIC_ORIGIN | Optional exact HTTPS origin without trailing slash, allowed when a client supplies Origin |
| Provider call | Fixed OpenAI URL or the configured Azure resource's /openai/v1/responses; one request, no retries, 512 output tokens, store:false, stream:false, tools:[] |
| Bounds | Four active requests per process, ten-second model deadline, upstream response capped at 65,536 bytes |
Incomplete, refused, empty, oversized, or failed model responses return an error.
The sample checks for exact credential leaks, but that is not a general guarantee against sensitive-data disclosure.
Review the provider's text-generation guidance when adapting the request.
The store:false request option is not a promise about all provider retention policies.
Deploy and connect
Commit and push changes to your fork, retaining its source, lockfile, tests, README, and root builder.yaml.
Authorize your fork using source control and keep the app source root at the repository root (".").
The included manifest selects a Node 24 web component on port 8080, starts node server.mjs, and checks /health for status 200.
Keep the fork, branch, and root builder.yaml you prepared above.
Builder deploys committed GitHub source, not uncommitted local files.
- Portal
- Builder CLI
Open the App Service Builder Portal.
Your Azure account needs permission to create and deploy Microsoft.Web/builderApps resources.
Creating a resource group also requires permission to create groups in the selected subscription.
- Sign in to the Portal with the Microsoft account authorized for your subscription.
- Select the subscription and choose Create.
- In Connect GitHub, sign in to GitHub and authorize the OAuth App. Keep Use my repository selected to deploy the fork you prepared above. Choose the account or organization that owns your fork, then select that repository and branch. Use Change account if you need a different GitHub account, or Refresh access after changing repository permissions. Select Next.
- In Choose approach, confirm the selected repository and branch. Keep Let Builder handle it selected. The App Service Builder GitHub App needs access to this repository to read your code, build it, and deploy your app. Signing in to GitHub alone does not grant this access. If prompted, select Install GitHub App and grant access to your selected repository, or add it to an existing installation. Close the GitHub window to refresh access, or select Refresh access after approval. Select Next when Builder is connected and GitHub App access confirmed are shown.
- In App details, enter an app name and select the subscription, resource group, and offered location. To create a resource group, select Create new, enter its name, and choose Resource group region. Select Add. The group appears as (new) and is created when you submit. Its region stores the resource group's metadata and does not change the app's region. Select Next.
- On Review and create, confirm the app, repository, branch, subscription, resource group, and app region. Select Create and deploy.
- Open the app's Deployments page and wait for the deployment to succeed. In Versions, inspect the source revision, component results, and build logs. Select Deploying to open an in-progress deployment's steps and logs. On Overview, use Browse to open the app URL.
Already prepared a fork? Keep Use my repository selected so you deploy that source, not a second copy. To start with a new sample instead, follow Create from a Portal template. Use GitHub Actions is marked Coming soon; use the Builder-managed approach for this preview.
If group creation fails, app creation does not start. If the group was created before a later failure, it remains in Azure; cancelling does not delete it. Check the existing group and app before retrying, and inspect a group's contents before deleting it separately.
See GitHub authorization requirements for organization approvals and SSO. If app creation succeeds but deployment cannot start, read the error and retry deployment on the existing app rather than creating a duplicate. For “Source revision does not contain builder.yaml”, push the missing manifest before retrying.
Choose a browser or terminal download.
Download in your browser: download Builder CLI 0.0.2 (azure-builder-cli-0.0.2.tgz) from the Private Preview release. Choose the CLI archive, not GitHub's automatic Source code ZIP or tarball.
Download from your terminal: with GitHub CLI installed, run this command in the directory where you want to save the archive:
gh release download builder-cli-v0.0.2-preview.1 --repo microsoft/azure-app-service-builder --pattern "azure-builder-cli-0.0.2.tgz"
The command downloads the CLI archive into the current directory.
It refuses to overwrite an existing file; choose another directory if the archive is already present.
Release archives use the name azure-builder-cli-<version>.tgz.
Use the same portable npm archive on Windows, Linux, and macOS; there is no separate OS/CPU-specific CLI download.
Install Node.js 22 or later, including npm.
Install or upgrade using your downloaded archive directly:
npm install --global "<path-to-downloaded-file.tgz>"
builder --version
builder --version should report 0.0.2.
Replace <path-to-downloaded-file.tgz> with the local path to your downloaded azure-builder-cli-0.0.2.tgz.
For the terminal download above, use ./azure-builder-cli-0.0.2.tgz while in the same directory.
Obtain preview access and confirm your approved subscription and location with your preview contact.
Do not extract the archive.
npm registry access is still required for JavaScript dependencies; access to Builder's private source repository is not required.
Installing the CLI does not grant preview access or install the separately distributed agent skills plugin.
The .NET runtime is needed only for local builder manifest commands.
You can install Builder and run builder login, builder init, and
builder app deploy without .NET.
The archive includes the local manifest analyzer and its dependencies, but not the .NET runtime.
For optional local manifest validation, install a compatible .NET 10 runtime and keep dotnet on PATH.
The analyzer requires Microsoft.NETCore.App 10.0.0 or a compatible runtime.
A .NET SDK is not required to use Builder; an existing compatible SDK's included runtime is sufficient.
Check installed runtimes with:
dotnet --list-runtimes
Use your installed Builder CLI and GitHub CLI (gh) to connect your source.
The App Service Builder GitHub App must have access to your selected repository so Builder can read, build, and deploy its code.
See GitHub authorization requirements if access has not been granted.
Reuse a resource group, or create one first with Azure CLI:
az login
az group create --subscription "<subscription-id>" \
--name "<resource-group>" --location "eastus2"
Replace the subscription and resource-group placeholders with your values.
You can use westus2 instead of eastus2.
Only this optional resource-group creation step requires Azure CLI and permission to create resource groups.
Builder CLI uses the group you select; it does not create it.
If you have not already cloned your prepared fork, copy its HTTPS clone URL from GitHub and run:
git clone "<your-fork-https-url>"
cd "<local-repository-directory>"
Run builder init from inside an initialized Git worktree.
GitHub sign-in does not select a local repository.
If your terminal is in your home directory, open your cloned app folder or change to it first.
Do not initialize Git in your home directory to get past the worktree error.
Run these commands from your app's checkout:
builder --help
builder login
builder account show
builder source login github
builder init
Follow the prompts and confirm the app name, Azure subscription, resource group, approved location, and GitHub source.
Select your prepared fork and its pushed branch.
Keep the app name, subscription ID, and resource group for the deployment commands below.
Initialization creates or reuses the app and connects source; it does not deploy or upload local changes.
For explicit automation, see non-interactive setup.
builder init does not automatically analyze or modify builder.yaml.
Deployment requires builder.yaml at the selected source root.
Review your manifest, then commit and push any changes you want to deploy.
Optionally validate the prepared manifest locally without changing files or running repository code. This step requires the separate .NET runtime described in the installation instructions; login, setup, and deployment do not:
builder manifest validate
Request deployment and read the app:
builder app deploy --name "<app-name>" \
--subscription "<subscription-id>" --resource-group "<resource-group>"
builder app show --name "<app-name>" \
--subscription "<subscription-id>" --resource-group "<resource-group>"
Deployment waits by default.
After success, use the runtime URL returned by app show for the checks below.
For a failure, inspect build and deployment diagnostics.
The CLI reference lists selectors, diagnostics, and flags.
For API automation, use the ARM API deployment guide with this same fork, branch, and source root ".".
ARM and Bicep infrastructure templates provision the resource; separately authorize and connect this source, then deploy it through CLI or ARM.
Use application variables to set app authentication and model configuration. PUBLIC_ORIGIN is optional for clients that supply Origin; server-side requests do not require it.
Choose Save and deploy to capture values in a new version, and follow that deployment to success.
There is no runtime-only secret toggle: variables are shared with builds and all components.
Keep this compute-only sample's build free of environment dumps, public asset embedding, and credential logging.
Saving values does not mutate a running version.
The public /health endpoint returns only process liveness, without calling the model or returning configuration.
The app requires its bearer credential and validates any supplied Origin value.
After success, use <returned-app-origin>/agent from an authorized server-side client with the same JSON contract.
Use HTTPS and retain the app token server-side.
The app binds 0.0.0.0:8080; Origin validation is not a substitute for isolated networking or authentication.
No browser CORS access is granted.
Verify an authenticated request to the deployed app and an actual response from your selected model service.
Local tests and health success alone do not prove that model requests work.
Authorization and safety
Deployed-app authentication covers the platform identity boundary separately from the sample app token.
For platform bearer access alongside sample authentication, send the platform credential in X-Embr-Authorization and the sample credential in Authorization.
The proxy consumes and removes Authorization when it uses that header for platform authentication.
Qualify credential acquisition, audiences, and forwarding on the target; browser login is not a machine-client credential.
Shared-token protection and a per-process concurrency cap are development safeguards, not per-user authorization, a distributed rate limit, or a cost budget.
Treat caller input and model output as untrusted. Do not send secrets or sensitive customer data in prompts. Before adding agent tools, validate the caller's scopes/roles and resource ownership server-side for every operation. A prompt, a model decision, or a tool annotation never authorizes writes. Side-effect tools require explicit authorization, bounded execution, and a confirmation design; this sample supplies none. Keep credentials out of source, request bodies, URLs, browser bundles, responses, and logs.
Troubleshooting
| Result | Check |
|---|---|
503 | Supply a valid app token and all explicit model settings, then deploy the captured version |
401 | Supply the exact app bearer credential and verify the platform header separately |
403 | A supplied Origin must match the exact configured origin |
400 or 415 | Send only bounded, nonblank message text as application/json |
429 | Wait for one of four active requests in this process to finish |
502 | Check provider access, model compatibility, and output limits without exposing upstream credentials/errors |
504 | The model deadline expired; investigate service latency before retrying |
Clean up
Stop local servers, unset credentials/configuration, and revoke the dedicated provider key.
Delete only the test app you created when you no longer need it. App deletion does not remove your GitHub repository, resource group, or separately owned services and user-assigned identities.
- Portal
- Builder CLI
Return to the app inventory and choose Delete from the test app's actions. Alternatively, open the app's Settings and select Delete under Danger zone. Confirm the selected app and follow deletion to completion. Deleting from Settings returns you to the home inventory after the deletion request is accepted.
builder app delete --name "<app-name>" \
--subscription "<subscription-id>" --resource-group "<resource-group>"
The command asks for confirmation and waits for deletion unless --no-wait is supplied.
If you choose not to wait, track the returned operation before treating cleanup as complete.
App deletion does not close the external service account. Before sharing the app, verify startup, health, authentication, and a real model request in your preview environment. Use this guide only for an application-owned assistant that calls a separately configured model service. Builder does not provide a managed agent runtime. Use host an MCP server to expose read-only tools to another client instead of owning the assistant's model request.