August 17, 2026

Reducing Token Usage for AI Agents: Markdown for Agents in Azure App Service

Apps on Azure

As AI agents become a core part of modern applications, they spend a lot of time reading data from web pages, APIs, and existing web apps. However, if you have ever fed raw HTML into a Large Language Model (LLM), you know how inefficient it can be. Standard web pages are packed with JavaScript tags, CSS styling, navigation menus, and boilerplate markup. Browsers need all of that to render a nice UI, but for an AI agent, it is mostly useless noise.

This extra noise directly leads to higher token usage, longer processing times, and increased API costs for your AI models.

To solve this problem, Microsoft recently announced the public preview of Markdown for Agents in Azure App Service. This built-in platform capability automatically converts HTML responses into clean, text-focused Markdown on the fly whenever an AI agent requests it—without requiring a single line of code change in your application. In this article, we will take a close look at how it works, why it matters for your AI workloads, and how to set it up step-by-step.

What is Markdown for Agents?

Markdown for Agents is a zero-code integration feature inside Azure App Service that inspects incoming HTTP requests. When an AI agent or LLM client calls your app with a specific content request header (Accept: text/markdown), App Service intercepts the response, strips out non-essential HTML markup, and converts the core content into Markdown before sending it back.

+-----------------------------------------------------------------------------------+
| AI Agent / LLM Client                                                             |
|                                                                                   |
|  +--------------------+        HTTP GET with 'Accept: text/markdown'              |
|  | AI Agent / SDK     | ------------------------------------+                     |
|  +--------------------+                                     |                     |
|                                                             v                     |
|                                         +---------------------------------------+ |
|                                         | Azure App Service Platform            | |
|                                         | (Intercepts & Converts HTML Response) | |
|                                         +---------------------------------------+ |
|                                                             |                     |
|                                                             | Native App Output   |
|                                                             v (HTML)              |
|                                                 +-----------------------+         |
|                                                 | Your Web Application  |         |
|                                                 | (No Code Changes)     |         |
|                                                 +-----------------------+         |
+-----------------------------------------------------------------------------------+

Key Technical Benefits

  • Automatic Token Reduction: By removing inline scripts, style tags, and structural HTML overhead, the size of the payload sent to your AI model drops dramatically. In internal Microsoft tests across more than 637,000 pages, converted Markdown responses were 97% smaller at the median compared to raw HTML.
  • Minimal Latency Overhead: The conversion engine is built directly into the App Service platform runtime. In tests, the median conversion time took just 2 milliseconds, keeping your end-to-end response times fast.
  • Zero Application Code Changes: Your web app continues to render standard HTML for regular web browsers. You do not need to rewrite your controllers, add extra endpoints, or build custom scraping pipelines.
  • Preserved Content Hierarchy: Core readability elements—such as headings, paragraphs, bullet lists, links, images, tables, code blocks, and emphasis—are preserved so the LLM retains full context.
  • Reused Security Boundaries: The feature operates within your existing app configuration. Your current Microsoft Entra ID settings, access policies, VNet integration, and custom authentication rules apply automatically.

Technical Prerequisites & Constraints

Before enabling the feature during the public preview phase, keep these current parameters in mind:

  • Platform Support: Available for Windows apps in all public Azure regions. Linux App Service support is scheduled to arrive later in the year.
  • Pricing Tier: Requires an App Service Plan in the Basic tier or higher (Basic, Standard, Premium, or Isolated).
  • API Version: Resource deployments must use Azure Resource Management (ARM) API version 2026-03-15 or newer.
  • Failback Behavior: If a page cannot be safely converted to Markdown, App Service gracefully falls back and returns the original HTML. Clients should always verify the Content-Type header in the response.

Implementation Guide

Setting up Markdown for Agents is straightforward. Below, we will cover how to enable it using the Azure CLI (az rest), deploy it via Bicep, and test the response using curl.

Enabling via Azure CLI

During the preview phase, management portal controls and dedicated CLI subcommands are still being developed. You can enable the feature immediately using az rest to send a PATCH request directly to the Azure Resource Manager API:

# Define your variables
SUBSCRIPTION_ID="your-subscription-id"
RESOURCE_GROUP="rg-appservice-demo"
APP_NAME="app-mywebpage-prod"

# Enable Markdown for Agents on your App Service instance
az rest --method patch \
  --url "https://management.azure.com/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Web/sites/${APP_NAME}?api-version=2026-03-15" \
  --headers "Content-Type=application/json" \
  --body '{"properties":{"aiIntegration":{"markdown":{"enabled":true}}}}'

To verify that the configuration was applied successfully, run a GET request:

az rest --method get \
  --url "https://management.azure.com/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Web/sites/${APP_NAME}?api-version=2026-03-15" \
  --query "properties.aiIntegration.markdown"

Declarative Infrastructure as Code (Bicep)

If you manage your Azure infrastructure declaratively, you can add the aiIntegration property directly inside your Bicep module:

param appName string
param location string = resourceGroup().location
param appServicePlanResourceId string

resource webApp 'Microsoft.Web/sites@2026-03-15' = {
  name: appName
  location: location
  properties: {
    serverFarmId: appServicePlanResourceId
    siteConfig: {
      netFrameworkVersion: 'v8.0'
    }
    aiIntegration: {
      markdown: {
        enabled: true
      }
    }
  }
}

Testing the Response with cURL

Once enabled, test your endpoint using curl by passing the Accept: text/markdown header:

curl -i -H "Accept: text/markdown" "https://app-mywebpage-prod.azurewebsites.net/"

When the conversion succeeds, your HTTP response headers will include:

HTTP/1.1 200 OK
Content-Type: text/markdown; charset=utf-8
x-markdown-source: easy-markdown

The response body will now contain clean Markdown text ready to be passed directly into your LLM prompt pipeline or AI agent framework.

Closing Words

The new Markdown for Agents feature in Azure App Service is a small change that brings a big efficiency win for team building AI-driven web applications. By automatically filtering out HTML bloat at the platform layer, you can significantly reduce token consumption, lower your LLM operational costs, and speed up agent execution times.

Thank you for taking the time to go through this post and making it to the end. Stay tuned, because we’ll keep continuing providing more content on topics like this in the future.

Author: Rolf Schutten

Posted on: August 17, 2026