azure-functions-agents
Build, scaffold, extend, deploy, and troubleshoot event-driven AI agents and scheduled serverless agent apps on Azure Functions using azurefunctions-agents-runtime. Use when the user wants a scheduled agent, morning briefing, daily digest, timer agent, inbox summary, email or Teams briefing, background AI workflow, connector-triggered agent, event-driven AI automation, HTTP/chat agent, webhook-style agent, or Azure Functions hosted agent. Covers .agent.md, agents.config.yaml, Foundry gpt-4.1/gpt-5.x model choice, dynamic sessions for code execution and web browsing, built-in chat/API/MCP endpoints, remote MCP servers, Connector Namespaces, Office 365 or Teams MCP tools/triggers, custom Python tools, Agent Skills, azd deployment, local.settings.json, Application Insights, local development, and troubleshooting.
NPX Install
npx skill4agent add anthonychu/skills azure-functions-agentsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Azure Functions Agents
Current Defaults
- Scaffold with Microsoft Foundry as the model provider.
- Scaffold files may keep as the safe Bicep fallback, but before provisioning or deploying, check the user's subscription/region for the best deployable GPT model and quota.
gpt-4.1 - Prefer the newest deployable GPT reasoning model with remaining quota when available, such as
or newer. Only configure reasoning settings for models known to support them. Older models can fail if
gpt-5.4settings are present.AZURE_FUNCTIONS_AGENTS_REASONING_* - For and other reasoning-capable models, use reasoning effort
gpt-5.xby default,highonly when the selected model supports it, and reasoning summaryxhigh.concise - If an agent needs web browsing, current public data, browser automation, data analysis, or code execution, use Azure Container Apps dynamic sessions. Do not write custom web-fetch tools for those cases.
- Use remote MCP servers and connection MCP servers from .
mcp.json - Use Connector Namespaces, represented as resources in Bicep.
Microsoft.Web/connectorGateways - Generated apps should include a ready-to-edit , not only a template.
src/local.settings.json - Generated must use the official PyPI package:
requirements.txt.azurefunctions-agents-runtime
Progressive References
| Need | Reference |
|---|---|
| Required files and scaffold contents | project-files.md |
| Agent frontmatter, triggers, built-in endpoints | agent-files.md |
| Trigger schemas, connector triggers, built-in endpoint routes | triggers.md |
| Built-in chat APIs, session IDs, built-in MCP tools | built-in-endpoints.md |
| Local/deployed testing recipes by trigger type | testing.md |
| Foundry model defaults, upgrades, reasoning settings | models.md |
| Dynamic sessions for code execution and web browsing | sessions.md |
| Connector Namespace overview, naming, and safety boundaries | connectors.md |
Connector MCP server configs, authorization, | connector-mcp.md |
| Connector operation IDs, schemas, dynamic parameters, and Teams target IDs | connector-schemas.md |
| Connector-triggered agents and trigger config deployment | connector-triggers.md |
| Custom Python tools and Agent Skills | tools-and-skills.md |
| Writing robust agent instructions | agent-authoring.md |
| Bicep, azd, deployment, local development | infra-and-deployment.md |
| Diagnostics and common failures | troubleshooting.md |
| Full quickstart app copied into this skill | quickstart-reference.md |
Assess the Workspace
- importing
src/function_app.pycreate_function_app() src/*.agent.mdsrc/agents.config.yamlsrc/mcp.json- and
src/tools/src/skills/ src/local.settings.json- ,
infra/main.bicep,infra/app/*.bicepinfra/main.parameters.json azure.yaml- for existing
.azure/*/config.jsonenvironmentsazd
builtin_endpointstrigger.argsagents.config.yamlmcp.jsonMicrosoft.Web/connectorGatewaysconnectorGateways/<gateway>/connectionsconnectorGateways/<gateway>/mcpserverconfigsconnectorGateways/<gateway>/triggerconfigsMicrosoft.Web/connectionsDiscuss and Plan the Agent
- Goal: What should the agent accomplish, and what should a successful run produce?
- Invocation: Should it be chat/API-driven, scheduled, event-triggered, connector-triggered, or some combination?
- Inputs and outputs: What data starts the run, and should the result be returned, logged, emailed, posted, drafted, stored, or sent somewhere else?
- Interactive surfaces: Does the user want to chat with the agent, expose a chat/API surface, stream responses, or expose the agent as a built-in MCP tool? Enable built-in endpoints only for those interactive scenarios.
- Tools and services: Does it need web/code execution, Microsoft Learn, Office 365, Teams, Azure Resource Manager, storage, queues, databases, or custom APIs?
- Teams targets: If the agent needs a Teams team, channel, or chat target, ask the user to paste a Teams link and parse IDs from it on their behalf. Do not ask them to manually find raw team IDs, channel IDs, or chat IDs.
- Safety boundaries: For actions like email, Teams posts, ticket creation, or resource changes, should the agent draft, ask for confirmation, or act automatically?
- Model selection: Which Azure subscription and region should be checked for GPT model access
and quota? If the user has not specified them, use the current Azure CLI subscription and the
planned .
AZURE_LOCATION - Deployment preference: Default to building and deploying to Azure with , but offer to run locally first if the user wants a local iteration loop.
azd up
host.jsonfunctionTimeoutbuiltin_endpointsmain.agent.mdScaffold a New App
<project-root>/
azure.yaml
infra/
abbreviations.json
main.bicep
main.parameters.json
app/
api.bicep
connector-gateway.bicep
trigger-config.bicep # if using connector triggers
foundry.bicep
rbac.bicep
session-pool.bicep
session-pool-rbac.bicep
src/
function_app.py
host.json
local.settings.json
requirements.txt
.funcignore
agents.config.yaml
main.agent.md # only when the user wants chat/API/MCP endpoints
<agent-name>.agent.md
mcp.json- Python 3.13 in Bicep.
- Foundry provider. Keep in template defaults only as a safe fallback.
gpt-4.1 - Before running or
azd provision, run the model and quota checks in models.md, recommend the best deployable GPT model, and set theazd up,FOUNDRY_MODEL,FOUNDRY_MODEL_NAME,FOUNDRY_MODEL_VERSION, and reasoning env vars when a better reasoning-capable model is selected.FOUNDRY_DEPLOYMENT_CAPACITY - No reasoning app settings unless the app is explicitly upgraded to a reasoning-capable model.
- ACA dynamic session pool when any agent needs code execution or web browsing.
- Optional Office 365 Outlook connection MCP server when is set.
TO_EMAIL - Built-in endpoints only when the scenario is interactive. Do not add debug chat UI, chat API,
streaming API, built-in MCP, or a general to a scheduled-only/background-only app unless the user asked for that surface.
main.agent.md - Explicit timeout settings: use in
functionTimeout: "00:30:00"for background-capable apps, keep simple chat/API agents athost.json, and set timer, connector-triggered, queue, or other long-running background agents totimeout: 900unless the task clearly needs more.timeout: 1800 - Connector-triggered apps use the preview extension bundle and a second-step trigger config
deployment after the system key exists.
connector_extension - includes local storage and Foundry/MCP placeholders.
local.settings.json
Local Development First Rule
azd up- Azure Developer CLI ()
azd - Azure Functions Core Tools v4
- Python 3.13+
- Azurite, when using
AzureWebJobsStorage=UseDevelopmentStorage=true - Azure CLI login for local managed-identity-equivalent access
azd provisionfunc startazd initazd provision- Copy outputs from into
azd env get-values.src/local.settings.json - Start Azurite with .
azurite --skipApiVersionCheck - From , create a venv, install requirements, and run
src.func start
Build or Modify Agents
.agent.mdbuiltin_endpoints---
name: Daily Report
description: Sends a daily report.
trigger:
type: timer_trigger
args:
schedule: "0 0 15 * * *"
mcp: true
------
name: Chat Agent
description: Interactive agent for testing.
builtin_endpoints:
debug_chat_ui: true
chat_api: true
mcp: true
mcp: false
---Model Selection Guidance
gpt-4.1az cognitiveservices model listaz cognitiveservices usage listgpt-4.1gpt-4.1gpt-4.1highxhighconciseDeploy and Verify
azd upazdazd initazd upazd provisionazd upaz account show --query "{name:name,id:id,tenantId:tenantId}"az account set --subscription <subscription-id>azd upazd pipeline configazd env get-values/agents/<slug>/az functionapp log tailazd upazd env get-valueshttps://learn.microsoft.com/api/mcp- Chat UI, when enabled:
/agents/<agent-file-stem>/ - Chat API, when enabled:
POST /agents/<agent-file-stem>/chat - Streaming chat API, when enabled:
POST /agents/<agent-file-stem>/chatstream - MCP endpoint, when enabled:
/runtime/webhooks/mcp - Manual non-HTTP trigger:
POST /admin/functions/<agent-file-stem>