Rediger

Use AI tools and models in Azure Functions

Azure Functions provides serverless compute resources that integrate with AI and Azure services to help you build cloud-hosted intelligent applications. This article surveys AI-related scenarios, integrations, and resources that you can use in your function apps.

Use the following table to choose an integration based on how work starts and how other components consume it:

Option Best fit Invocation model Key considerations
Azure Functions hosted skills Add AI reasoning to event-driven workloads by using declarative instructions and tools. Functions triggers or optional built-in HTTP and MCP endpoints Preview
Model Context Protocol (MCP) endpoint implementations Expose synchronous, reusable tools to Microsoft Foundry agents and other MCP clients. Streamable HTTP Choose among hosted skills, the generally available MCP extension, and preview SDK-based hosting.
Queue-based Azure Functions tools Run asynchronous background tools for Microsoft Foundry agents. Azure Queue Storage input and output queues Foundry-specific; requires a Foundry agent with the standard setup.
Agentic workflows Coordinate long-running or multistep AI work that must survive restarts and waits. Durable orchestrations started by application events Choose direct Durable Functions orchestration or hosted-skills dynamic workflows.

This article is language-specific, so make sure you choose your programming language at the top of the page.

Azure Functions hosted skills

Azure Functions hosted skills is a programming model for building cloud-hosted, event-driven intelligent capabilities on Azure Functions. You define behavior with Markdown, natural-language instructions, and declarative configuration. The runtime discovers .agent.md files, registers triggers and endpoints, and runs hosted skills when events fire.

Important

Azure Functions hosted skills is currently in preview. Features, configuration names, and supported connectors can change before general availability.

You don't need to write Python code to define a hosted skill. You define its behavior, triggers, and configured tools in Markdown and configuration files. If you need custom app logic beyond these configured capabilities, you can add custom Python tools.

Use Azure Functions hosted skills when you want to add intelligent behavior to an event-driven application in response to an HTTP request, schedule, message, data change, an event from a managed connector, or other event. You can also enable an optional built-in MCP endpoint that exposes each hosted skill as an AI-powered tool for other applications, agents, or agent harnesses.

To get started, see these articles:

Tools and MCP servers

AI models and agents use function calling to request external resources known as tools. By using function calling, models and agents can dynamically invoke specific functionality based on the context of a conversation or task.

Functions is particularly well-suited for implementing function calling in agentic workflows because it efficiently scales to handle demand and provides binding extensions that simplify connecting agents with remote Azure services. When you build or host AI tools in Functions, you also get serverless pricing models and platform security features.

MCP is the industry standard for interacting with remote servers. It provides a standardized way for AI models and agents to communicate with external systems. By using an MCP server, these AI clients can efficiently determine the tools and capabilities of an external system.

Azure Functions currently supports exposing your function code by using these types of tools:

Tool type Description
Built-in MCP endpoint for hosted skills Expose hosted skills that apply AI reasoning as tools through a built-in MCP endpoint.
Remote MCP server Create deterministic MCP tools or host SDK-based MCP servers for synchronous tool calls.
Queue-based Azure Functions tool Use the Microsoft Foundry-specific tool for asynchronous function calling through message queues.

Choose how to expose an MCP endpoint

Functions supports these options for exposing capabilities through MCP:

  • Enable the built-in MCP endpoint for Azure Functions hosted skills to expose AI-powered tools defined in .agent.md files. Hosted skills are currently in preview.
  • Use the MCP binding extension to create and host deterministic MCP tools as you would any other function app.
  • Self-host MCP servers created by using the official MCP SDKs. This hosting option is currently in preview.

Here's a comparison of the current MCP endpoint options provided by Functions:

Feature Built-in MCP endpoint for hosted skills MCP binding extension Self-hosted MCP servers
Best fit Expose an AI-powered hosted skill as an MCP tool. Build deterministic MCP tools with Functions triggers and bindings. Host an existing server built with an official MCP SDK.
Current support level Preview Generally available Preview*
Programming model .agent.md hosted skill Functions triggers and bindings Standard MCP SDKs
Stateful execution Session history supported Supported Not currently supported
Custom code languages Python (optional custom tools) C# (isolated process)
Python
TypeScript
JavaScript
Java
C# (isolated process)
Python
TypeScript
Java
Hosting plan Flex Consumption
Premium
Dedicated (App Service)
Supported Azure Functions hosting plans Flex Consumption only
Other requirements Enable builtin_endpoints.mcp in the hosted skill None Stateless server that uses Streamable HTTP transport
How implemented Built-in MCP endpoint in the hosted-skills runtime MCP binding extension Custom handlers

*Configuration details for self-hosted MCP servers change during the preview.

Use the following language-specific resources to get started with remote MCP servers in Functions:

For C#, compare these resources for the MCP extension and SDK-based hosting:

Options MCP binding extension Self-hosted MCP servers
Documentation MCP binding extension Not applicable
Samples Remote custom MCP server Weather server
Templates HelloTool Not applicable

For Python, compare these resources for the MCP extension and SDK-based hosting:

Options MCP binding extension Self-hosted MCP servers
Documentation MCP binding extension Not applicable
Samples Remote custom MCP server Weather server

For TypeScript, compare these resources for the MCP extension and SDK-based hosting:

Options MCP binding extension Self-hosted MCP servers
Documentation MCP binding extension Not applicable
Samples Remote custom MCP server Weather server

For JavaScript, use the MCP extension resources. SDK-based hosting is supported, but a JavaScript quickstart isn't currently available.

Options MCP binding extension Self-hosted MCP servers
Documentation MCP binding extension Not applicable
Samples Not yet available Not yet available

For Java, use the MCP extension documentation. Language-specific samples aren't currently available.

Options MCP binding extension Self-hosted MCP servers
Documentation MCP binding extension Not applicable
Samples Not yet available Not yet available

PowerShell isn't currently supported for either MCP server hosting option.

Choose queue-based Azure Functions tools for Microsoft Foundry Agent Service

Microsoft Foundry Agent Service also provides an Azure Functions-specific tool for asynchronous function calling. The agent places a request in an Azure Queue Storage input queue. A queue-triggered function processes the request and returns the result through an output queue.

Use this Foundry-specific integration for background operations that don't require an immediate response and benefit from reliable message delivery and retries. For synchronous interactions or tools that you want to reuse with other AI clients, use an MCP server instead.

Queue-based Azure Functions tools require a Foundry agent with the standard setup. To review supported SDKs and build a tool, see Use Azure Functions with Foundry Agent Service.

Agentic workflows

Use Durable Functions when your application code defines a reliable sequence of agent calls, model calls, approvals, and other work. Durable Functions preserves orchestration state across waits and restarts and supports common patterns such as function chaining, fan-out/fan-in, and human interaction.

If you use Azure Functions hosted skills, dynamic workflows provide a preview option in which a model creates a structured plan of tool calls, subagent tasks, and waits. The hosted-skills runtime executes that plan as a Durable Functions orchestration. Use direct tool calling when work can finish in one interaction, and use a dynamic workflow when work must run beyond a single turn, fan out, wait, or survive restarts.

Option Who defines the workflow Best fit Key considerations
Direct Durable Functions orchestration Application code Predictable workflows with explicit control flow, retries, waits, and approvals Use the Durable Functions programming model for your language.
Hosted-skills dynamic workflow AI model Adaptive workflows that plan tool calls, subagent tasks, waits, and fan-out at runtime Preview; requires Azure Functions hosted skills.

For implementation guidance, see Application patterns and Create and run dynamic workflows.

AI tools and frameworks for Azure Functions

With Functions, you can build apps in your preferred language and use your favorite libraries. Because of this flexibility, you can use a wide range of AI libraries and frameworks in your AI-enabled function apps.

These Microsoft AI platforms and frameworks support different application architectures:

Platform or framework Best fit How it works with Azure Functions
Microsoft Agent Framework Code-first agent logic and workflows that run in your application Run the framework SDKs in your function code.
Microsoft Foundry Agent Service Managed agents that use Functions-hosted tools Create and manage agents as a hosted service. Foundry agents can call tools hosted by Functions through MCP, queues, or OpenAPI.
Microsoft Foundry SDKs Direct model and service calls that don't require a managed agent Call Foundry models and services directly from your function code.

In Functions, your apps can also reference third-party libraries and frameworks, so you can use all of your favorite AI tools and libraries in your AI-enabled functions.