Skip to content

Decide each tool call behind Azure API Management

Put an MCP server behind Azure API Management with Keycard sign-in, and let Keycard policy allow or refuse each tool call, with no Keycard secret stored in APIM.

Azure API Management (APIM) can sit in front of an MCP server as the place access is enforced, with Keycard deciding each tool call. Using only built-in policies, APIM asks Keycard about every MCP request and forwards it only if Keycard policy allows that tool, and it proves its own identity to Keycard with its managed identity, so APIM stores no Keycard secret.

  1. MCP client Signs the person in through Keycard and calls a tool through APIM with a token for APIM’s endpoint.
  2. Azure API Management Checks the token, then exchanges it with Keycard, names the tool in the request, and proves its own identity with a token for its managed identity.
  3. Keycard Decides through policy whether that person may call that tool, and issues a token for the MCP server or refuses with a reason.
  4. Orders MCP server Receives the call with the new token, or never sees it, while APIM answers 403 with Keycard’s reason.
  • A Keycard organization where you have the Admin Role. Your issuer URL is under Settings → Connection in Keycard Console, and has the form https://<zone-id>.keycard.cloud.
  • A Service Account credential, exchanged for a Management API token in ACCESS_TOKEN. Add a credential and Use the credential show how.
  • An Azure API Management instance on the Developer tier, with its system-assigned managed identity turned on. A new instance takes 30 to 45 minutes to create. You need the managed identity’s object ID, written <managed-identity-object-id> on this page, and your Microsoft Entra tenant ID, written <tenant-id>.
  • An Azure Container Registry and an Azure Container Apps environment for the orders MCP server. APIM runs in Azure, so it can’t reach a server on your laptop.
  • Permission to register an application in Microsoft Entra ID.
  • The Azure CLI, signed in with az login, plus curl, jq, and Python 3.
  • The orders MCP server from keycardai/tutorial-kong-mcp, cloned. Its orders-mcp folder holds a server with one tool that reads orders, list_orders, and one that refunds them, refund_order.
  • An MCP client. This recipe uses Claude Code.

This recipe was tested on the Developer tier of Azure API Management, with FastMCP 4.1.6 in the orders server.

This recipe assumes your organization runs the managed default-zone-policies Policy Set, which allows every tool. If you run a Policy Set of your own, make sure it lets you call the orders server’s tools through APIM. See Access Policies.

  1. Add a Dockerfile

    Save this as orders-mcp/Dockerfile in your clone:

    FROM python:3.13-slim
    RUN pip install --no-cache-dir uv==0.9.5
    WORKDIR /app
    COPY pyproject.toml uv.lock ./
    COPY src ./src
    RUN uv sync --frozen --no-dev
    ENV HOST=0.0.0.0 PORT=8090
    EXPOSE 8090
    CMD ["uv", "run", "--no-sync", "orders-mcp"]
  2. Deploy it to Azure Container Apps

    Build the image from the orders-mcp folder in your Azure Container Registry, and deploy it to Azure Container Apps with HTTPS ingress on port 8090 and minimum replicas set to 1. Let the app pull from the registry with its managed identity.

    Note the app’s host name, such as <app-name>.<environment>.<region>.azurecontainerapps.io, as <orders-host>. The orders server answers at https://<orders-host>/mcp. Until you set its environment in Lock the orders server to APIM, it accepts any request.

Register APIM and the orders server in Keycard

Section titled “Register APIM and the orders server in Keycard”

These requests register APIM’s endpoint and the orders server as Resources, and give APIM an Application to exchange tokens as.

  1. Set up the requests

    Terminal window
    export ACCESS_TOKEN=<management-api-token>
    APIM_ENDPOINT=https://<apim-name>.azure-api.net/orders/mcp
    ORDERS_RESOURCE=https://<orders-host>/mcp
    kc() {
    local m="$1" p="$2"
    shift 2
    curl -s --fail-with-body -X "$m" "https://api.keycard.ai/zones/<zone-id>$p" \
    -H "Authorization: Bearer $ACCESS_TOKEN" -H 'Content-Type: application/json' "$@"
    }
    STS_PROVIDER_ID=$(kc GET '/providers?type=keycard-sts' | jq -r '.items[0].id')

    STS_PROVIDER_ID holds Keycard’s own Provider, Zone Provider in Console. Both Resources use it.

  2. Register APIM’s endpoint as a Resource

    Terminal window
    ENDPOINT_ID=$(kc POST /resources -d "{
    \"name\": \"Orders MCP (through APIM)\",
    \"identifier\": \"$APIM_ENDPOINT\",
    \"scopes\": [\"mcp:tools\"],
    \"credential_provider_id\": \"$STS_PROVIDER_ID\"
    }" | jq -r .id)

    The MCP client gets a token for this Resource when the person signs in, and sends it to APIM.

  3. Create APIM’s Application

    Terminal window
    APP_ID=$(kc POST /applications -d '{"name": "Azure API Management", "identifier": "azure-api-management"}' | jq -r .id)

    APIM exchanges tokens as this Application.

  4. Make APIM’s Application provide its endpoint

    Terminal window
    kc PATCH "/resources/$ENDPOINT_ID" -d "{\"application_id\": \"$APP_ID\"}"

    Only the Application that provides a Resource can exchange tokens issued for it.

  5. Register the orders server as a Resource

    Terminal window
    ORDERS_ID=$(kc POST /resources -d "{
    \"name\": \"Orders MCP server\",
    \"identifier\": \"$ORDERS_RESOURCE\",
    \"credential_provider_id\": \"$STS_PROVIDER_ID\"
    }" | jq -r .id)
  6. Let APIM reach the orders server

    Terminal window
    kc PUT "/applications/$APP_ID/dependencies/$ORDERS_ID?when_accessing=$ENDPOINT_ID"

    APIM’s Application can now get tokens for the orders server, but only when a caller is using APIM’s endpoint.

Let APIM authenticate with its managed identity

Section titled “Let APIM authenticate with its managed identity”

APIM proves to Keycard that it’s the Azure API Management Application with a token for its managed identity, so it needs no Keycard client ID or secret.

  1. Use an app registration for Keycard in Microsoft Entra ID

    Use the app registration that stands for Keycard, or create one as Create an app registration for Keycard describes. Its App ID URI is api://<keycard-audience-app-id>.

    APIM asks Entra for a managed identity token with this URI as its audience. A token for an app with no credentials is useless anywhere else, while a token for an Azure service, such as Azure Resource Manager, would also work against Azure.

  2. Register Microsoft Entra ID as a Provider

    If Keycard already has a Provider for your tenant’s v1 issuer, such as one from Register your tenant as a Provider, set ENTRA_PROVIDER_ID to its ID and skip this step.

    Terminal window
    ENTRA_PROVIDER_ID=$(kc POST /providers -d '{
    "name": "Microsoft Entra ID (v1 tokens)",
    "identifier": "https://sts.windows.net/<tenant-id>/",
    "protocols": {"oauth2": {"issuer": "https://sts.windows.net/<tenant-id>/"}}
    }' | jq -r .id)

    APIM’s managed identity tokens are Entra v1 tokens, so the Provider’s issuer is your tenant’s v1 issuer, https://sts.windows.net/<tenant-id>/.

  3. Add a Workload Identity credential for the managed identity

    Terminal window
    kc POST /application-credentials -d "{
    \"application_id\": \"$APP_ID\",
    \"type\": \"token\",
    \"provider_id\": \"$ENTRA_PROVIDER_ID\",
    \"subject\": \"<managed-identity-object-id>\"
    }"

    Keycard now accepts a token from that issuer, with the managed identity’s object ID as its subject, as proof that the caller is APIM’s Application.

  1. Set the server’s environment

    Set these environment variables on the orders server’s Container App:

    Variable Value
    KEYCARD_ISSUER https://<zone-id>.keycard.cloud
    GATEWAY_CLIENT_ID <managed-identity-object-id>
    ORDERS_RESOURCE https://<orders-host>/mcp

    Keycard puts the identifier of the credential APIM authenticated with in the client_id of each token it issues, and for this Workload Identity credential that’s the managed identity’s object ID. The server now accepts a token only if Keycard issued it for this server with that client_id, and logs accepted a token for sub=<user-id> from the gateway for each one.

These steps load the API, its named values, and its policy into APIM through Azure Resource Manager. The API is a plain HTTP API rather than APIM’s MCP server type: the MCP server type routes only the MCP endpoint and answers the metadata path with its own 404 before any policy runs, so the metadata would need a second API.

  1. Set up the requests

    Terminal window
    APIM="https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>"
    arm_put() { az rest --method put --url "$APIM$1?api-version=2022-08-01" --headers Content-Type=application/json --body "$2" -o none; }
  2. Create the named values

    Terminal window
    arm_put /namedValues/kc-zone-url '{"properties": {"displayName": "kc-zone-url", "value": "https://<zone-id>.keycard.cloud", "secret": false}}'
    arm_put /namedValues/kc-endpoint '{"properties": {"displayName": "kc-endpoint", "value": "https://<apim-name>.azure-api.net/orders/mcp", "secret": false}}'
    arm_put /namedValues/kc-orders-resource '{"properties": {"displayName": "kc-orders-resource", "value": "https://<orders-host>/mcp", "secret": false}}'
    arm_put /namedValues/kc-assertion-resource '{"properties": {"displayName": "kc-assertion-resource", "value": "api://<keycard-audience-app-id>", "secret": false}}'
    Named value Holds
    kc-zone-url Your Keycard issuer URL
    kc-endpoint APIM’s endpoint, which is also its Resource identifier in Keycard
    kc-orders-resource The orders server’s Resource identifier
    kc-assertion-resource The App ID URI of the app registration for Keycard

    None of them is a secret.

  3. Create the API and its operations

    Terminal window
    arm_put /apis/orders-mcp '{"properties": {"displayName": "Orders MCP", "path": "orders/mcp", "protocols": ["https"], "serviceUrl": "https://<orders-host>", "subscriptionRequired": false, "apiType": "http"}}'
    arm_put /apis/orders-mcp/operations/post-root '{"properties": {"displayName": "POST /", "method": "POST", "urlTemplate": "/"}}'
    arm_put /apis/orders-mcp/operations/get-root '{"properties": {"displayName": "GET /", "method": "GET", "urlTemplate": "/"}}'
    arm_put /apis/orders-mcp/operations/delete-root '{"properties": {"displayName": "DELETE /", "method": "DELETE", "urlTemplate": "/"}}'
    arm_put /apis/orders-mcp/operations/get-prm '{"properties": {"displayName": "GET /.well-known/oauth-protected-resource", "method": "GET", "urlTemplate": "/.well-known/oauth-protected-resource"}}'

    APIM serves the API at https://<apim-name>.azure-api.net/orders/mcp, with POST, GET, and DELETE on / for MCP and GET on the metadata path.

  4. Save the policy

    Save this as apim-policy.xml. How the policy fits together explains each part.

    <policies>
    <inbound>
    <base />
    <choose>
    <when condition="@(context.Request.Url.Path.EndsWith("/.well-known/oauth-protected-resource"))">
    <return-response>
    <set-status code="200" reason="OK" />
    <set-header name="Content-Type" exists-action="override">
    <value>application/json</value>
    </set-header>
    <set-body>{"resource":"{{kc-endpoint}}","authorization_servers":["{{kc-zone-url}}"],"scopes_supported":["mcp:tools"],"bearer_methods_supported":["header"]}</set-body>
    </return-response>
    </when>
    </choose>
    <validate-jwt header-name="Authorization" require-scheme="Bearer" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized">
    <openid-config url="{{kc-zone-url}}/.well-known/openid-configuration" />
    <audiences>
    <audience>{{kc-endpoint}}</audience>
    </audiences>
    <issuers>
    <issuer>{{kc-zone-url}}</issuer>
    </issuers>
    </validate-jwt>
    <set-variable name="kcDetail" value="@{
    var server = "{{kc-orders-resource}}";
    var text = context.Request.Body == null ? "" : context.Request.Body.As<string>(preserveContent: true);
    JToken parsed = null;
    if (!string.IsNullOrWhiteSpace(text)) {
    try { parsed = JToken.Parse(text); } catch (Exception) { return "BAD:Request body is not JSON"; }
    }
    if (parsed is JArray) { return "BAD:Send one JSON-RPC message per request"; }
    var action = "initialize";
    string name = null;
    var msg = parsed as JObject;
    if (msg?["method"]?.Type == JTokenType.String) {
    var m = (string)msg["method"];
    if (m == "tools/call") {
    var p = msg["params"] as JObject;
    name = (p?["name"]?.Type == JTokenType.String) ? (string)p["name"] : null;
    if (name == null || !System.Text.RegularExpressions.Regex.IsMatch(name, "^[A-Za-z0-9_.-]+$")) {
    return "BAD:tools/call needs a valid tool name";
    }
    action = "tools/call";
    } else if (m == "tools/list" || m == "prompts/list" || m == "resources/list" || m == "resources/templates/list") {
    action = m;
    }
    }
    var d = new JObject();
    d.Add("type", "mcp");
    d.Add("action", action);
    if (name != null) { d.Add("name", name); }
    d.Add("locations", new JArray(server));
    return new JArray(d).ToString(Newtonsoft.Json.Formatting.None);
    }" />
    <choose>
    <when condition="@(((string)context.Variables["kcDetail"]).StartsWith("BAD:"))">
    <return-response>
    <set-status code="400" reason="Bad Request" />
    <set-header name="Content-Type" exists-action="override">
    <value>application/json</value>
    </set-header>
    <set-body>@(new JObject(new JProperty("error", "invalid_request"), new JProperty("error_description", ((string)context.Variables["kcDetail"]).Substring(4))).ToString())</set-body>
    </return-response>
    </when>
    </choose>
    <authentication-managed-identity resource="{{kc-assertion-resource}}" output-token-variable-name="kcMiToken" ignore-error="false" />
    <set-variable name="kcForm" value="@{
    var auth = context.Request.Headers.GetValueOrDefault("Authorization", "");
    var subject = auth.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase) ? auth.Substring(7).Trim() : "";
    return "grant_type=" + Uri.EscapeDataString("urn:ietf:params:oauth:grant-type:token-exchange")
    + "\u0026subject_token=" + Uri.EscapeDataString(subject)
    + "\u0026subject_token_type=" + Uri.EscapeDataString("urn:ietf:params:oauth:token-type:access_token")
    + "\u0026resource=" + Uri.EscapeDataString("{{kc-orders-resource}}")
    + "\u0026authorization_details=" + Uri.EscapeDataString((string)context.Variables["kcDetail"])
    + "\u0026client_assertion_type=" + Uri.EscapeDataString("urn:ietf:params:oauth:client-assertion-type:jwt-bearer")
    + "\u0026client_assertion=" + Uri.EscapeDataString((string)context.Variables["kcMiToken"]);
    }" />
    <send-request mode="new" response-variable-name="kcExchange" timeout="20" ignore-error="false">
    <set-url>{{kc-zone-url}}/oauth/2/token</set-url>
    <set-method>POST</set-method>
    <set-header name="Content-Type" exists-action="override">
    <value>application/x-www-form-urlencoded</value>
    </set-header>
    <set-body>@((string)context.Variables["kcForm"])</set-body>
    </send-request>
    <choose>
    <when condition="@(((IResponse)context.Variables["kcExchange"]).StatusCode != 200)">
    <return-response>
    <set-status code="403" reason="Forbidden" />
    <set-header name="Content-Type" exists-action="override">
    <value>application/json</value>
    </set-header>
    <set-body>@{
    var r = (IResponse)context.Variables["kcExchange"];
    string reason = "status " + r.StatusCode;
    try {
    var j = r.Body.As<JObject>();
    if (j?["error_description"] != null) { reason = (string)j["error_description"]; }
    } catch (Exception) { }
    return new JObject(new JProperty("error", "access_denied"), new JProperty("error_description", "Keycard refused this call: " + reason)).ToString();
    }</set-body>
    </return-response>
    </when>
    </choose>
    <set-header name="Authorization" exists-action="override">
    <value>@("Bearer " + (string)((IResponse)context.Variables["kcExchange"]).Body.As<JObject>()["access_token"])</value>
    </set-header>
    <rewrite-uri template="/mcp" copy-unmatched-params="true" />
    </inbound>
    <backend>
    <forward-request timeout="120" buffer-response="false" />
    </backend>
    <outbound>
    <base />
    </outbound>
    <on-error>
    <base />
    <choose>
    <when condition="@(context.LastError?.Source == "validate-jwt")">
    <return-response>
    <set-status code="401" reason="Unauthorized" />
    <set-header name="WWW-Authenticate" exists-action="override">
    <value>Bearer resource_metadata="{{kc-endpoint}}/.well-known/oauth-protected-resource", scope="mcp:tools"</value>
    </set-header>
    <set-header name="Content-Type" exists-action="override">
    <value>application/json</value>
    </set-header>
    <set-body>{"error":"invalid_token","error_description":"Sign in through the Keycard zone"}</set-body>
    </return-response>
    </when>
    </choose>
    </on-error>
    </policies>
  5. Apply the policy

    Terminal window
    python3 -c 'import json, sys; print(json.dumps({"properties": {"format": "rawxml", "value": open(sys.argv[1]).read()}}))' apim-policy.xml > apim-policy.json
    arm_put /apis/orders-mcp/policies/policy @apim-policy.json
  1. Send a request without a token

    Terminal window
    curl -i -X POST https://<apim-name>.azure-api.net/orders/mcp \
    -H 'content-type: application/json' \
    -H 'accept: application/json, text/event-stream' \
    -d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}},"id":1}'

    APIM answers 401, and the WWW-Authenticate header points at the metadata:

    WWW-Authenticate: Bearer resource_metadata="https://<apim-name>.azure-api.net/orders/mcp/.well-known/oauth-protected-resource", scope="mcp:tools"
  2. Read the metadata

    Terminal window
    curl -s https://<apim-name>.azure-api.net/orders/mcp/.well-known/oauth-protected-resource

    The metadata names your Keycard issuer:

    {"resource":"https://<apim-name>.azure-api.net/orders/mcp","authorization_servers":["https://<zone-id>.keycard.cloud"],"scopes_supported":["mcp:tools"],"bearer_methods_supported":["header"]}
  1. Add the server to Claude Code

    Terminal window
    claude mcp add --transport http orders https://<apim-name>.azure-api.net/orders/mcp
    claude
  2. Sign in

    Run /mcp, select orders, then Authenticate. Claude Code reads APIM’s metadata and opens Keycard’s sign-in page. Sign in, then ask Claude to list the orders.

  3. Check the result

    Keycard’s default policies allow every tool, so Claude lists three orders. The orders server logs accepted a token for sub=<user-id> from the gateway for each request APIM forwarded.

    In Keycard Console, the Audit Log shows your sign-in as a credentials:issue with the authorization_code grant for the Orders MCP (through APIM) Resource. After that comes one credentials:issue with the token exchange grant for each MCP request, issued to you through the Azure API Management Application.

Take one tool away and check that APIM refuses it while the other keeps working. These requests copy Keycard’s default policies as the Policy Set apim-tutorial, add a policy that forbids refund_order on the orders server, and activate the copy.

  1. Copy the default policies

    Terminal window
    DEFAULT_SET_ID=$(kc GET /policy-sets | jq -r '.items[] | select(.name == "default-zone-policies") | .id')
    SET_ID=$(kc POST "/policy-sets/$DEFAULT_SET_ID/clones" -d '{"name": "apim-tutorial", "copy_policies": "none"}' | jq -r .policy_set.id)
  2. Forbid refunds and activate the copy

    Save this policy as orders-no-refunds.cedar, with your orders server’s Resource identifier:

    @id("orders-no-refunds")
    forbid (
    principal,
    action == Keycard::Action::"mcp::tools/call::refund_order",
    resource
    ) when {
    resource.identifier == "https://<orders-host>/mcp"
    };

    Add it to the copy, keeping every policy the copy already has, and activate the copy:

    Terminal window
    kc GET "/policy-sets/$SET_ID/manifest" | jq --rawfile cedar orders-no-refunds.cedar '{
    schema_version,
    activate: true,
    entries: ([(.entries // [])[] | {policy_id, policy_version_id}]
    + [{new_policy: {name: "orders-no-refunds", description: "Nobody may refund an order through APIM"}, cedar_raw: $cedar}])
    }' > manifest.json
    kc PUT "/policy-sets/$SET_ID/manifest" -d @manifest.json
  3. Ask for a refund

    Ask Claude to refund order A-1002. APIM answers 403 with this error_description, and Claude shows Keycard’s reason:

    Keycard refused this call: Action "mcp::tools/call::refund_order" on "Orders MCP server" is denied by Policy "orders-no-refunds" in version 2 of Policy Set "apim-tutorial".

    The version number can differ.

  4. List the refunded orders

    Ask Claude to list the refunded orders. Listing still works, and the list is empty, because the refund never reached the orders server. The Audit Log shows the refund’s exchange as a credentials:issue failure with the same reason.

To give refunds back, activate default-zone-policies again in Console. To take them away again, activate apim-tutorial in Console.

Sign-in, at the top of inbound and in on-error:

  • For a request whose path ends in /.well-known/oauth-protected-resource, APIM answers with the metadata itself, before it checks any token. The metadata names kc-endpoint as the resource and kc-zone-url as the authorization server.
  • In validate-jwt, APIM checks the caller’s token against Keycard’s OpenID discovery document at kc-zone-url, and accepts it only if Keycard issued it for kc-endpoint.
  • APIM can’t set the WWW-Authenticate header from validate-jwt, so when the token check fails, APIM answers 401 from on-error, with a header that points at the metadata.

The exchange, in the rest of inbound:

  • In the kcDetail expression, APIM reads the JSON-RPC body and names what it asks Keycard about: the tool for tools/call, the method for tools/list, prompts/list, resources/list, and resources/templates/list, and initialize for everything else. A policy can decide each tool call and each of those list methods, but not other methods. APIM answers a batch, a body that isn’t JSON, or a tools/call without a valid tool name with 400 before it asks Keycard.
  • With authentication-managed-identity, APIM gets a token for its managed identity whose audience is kc-assertion-resource.
  • In the kcForm expression, APIM builds the token exchange form: the caller’s token as subject_token, kc-orders-resource as resource, the tool in authorization_details, and the managed identity token as client_assertion. APIM URL-encodes each field itself, because it sends a send-request body as is, and joins the fields with "\u0026", because a literal & breaks a rawxml policy.
  • APIM sends no client_id. Keycard matches the managed identity token to the Workload Identity credential by its issuer and subject. With a client_id, Keycard looks the credential up a different way and refuses this one.
  • APIM has no cache policy here, so it asks Keycard on every request and each call gets its own decision.
  • If Keycard answers with anything but 200, APIM answers 403 with Keycard refused this call: followed by Keycard’s error_description. Otherwise APIM replaces the caller’s token with the one Keycard issued, so the caller’s token never reaches the orders server.

Forwarding, in backend:

  • APIM forwards each request to https://<orders-host>/mcp.
  • Setting buffer-response="false" on forward-request makes APIM stream the orders server’s responses, as MCP needs. APIM never reads the response body in this policy, because reading it would turn buffering back on.

APIM can also authenticate its exchange with a client secret, sent in a Basic header from a secret named value, but then APIM stores a Keycard secret.

Terminal window
rm apim-policy.xml apim-policy.json orders-no-refunds.cedar manifest.json

If APIM, the registry, and the orders server’s Container App are in a resource group of their own, delete it:

Terminal window
az group delete --name <resource-group>

Delete the app registration for Keycard in Microsoft Entra ID if no agent uses it. In Keycard Console, activate default-zone-policies again, then remove the apim-tutorial Policy Set, the Azure API Management Application, the Microsoft Entra ID (v1 tokens) Provider, and both Resources if you no longer need them.

  • The format APIM uses to name the tool in its exchange request, an RFC 9396 authorization detail, is provisional and may change.
  • This recipe was tested only on APIM’s Developer tier.
  • APIM asks Keycard on every request, so each call is its own decision and adds a round trip to Keycard.
  • The token Keycard issues for the MCP server doesn’t say which tool it was issued for. The MCP server has to accept only tokens Keycard issued to APIM, so nothing reaches it without APIM’s per-call decision.
  • The client_id in tokens Keycard issues to APIM is the identifier of the credential APIM authenticated with. If APIM moves to a different credential, client_id changes, while keycard_app_id stays the same.
  • If calls get 404 right after you create the API, APIM hasn’t finished rolling it out. Retry, and the same call gets 401.
  • If the policy breaks after you edit it, or after you paste it through another tool, look for a literal &. In the rawxml format, a literal & anywhere breaks the policy, expressions included. Join strings with "\u0026" and use ?. instead of &&, as the policy on this page does. Some tools turn \u0026 back into & when you paste through them, so save the policy straight from this page.
  • If calls get 403 with Keycard refused this call: No token application credential configured for provider and the issuer and subject Keycard read, Keycard has no Workload Identity credential that matches the managed identity’s token. Check that the Provider’s issuer is https://sts.windows.net/<tenant-id>/ and that the credential’s subject is the managed identity’s object ID.
  • If the orders server refuses every token after you change how APIM authenticates to Keycard, the tokens now carry a different client_id. Set GATEWAY_CLIENT_ID to the identifier of the credential APIM now uses.
  • If a call gets 400 before APIM asks Keycard, the request was a batch, a body that isn’t JSON, or a tools/call without a valid tool name. The error_description says which.
  • If the first call after a quiet spell waits about 25 seconds, or its connection drops, the orders server’s Container App scaled to zero. Set its minimum replicas to 1.
  • If the orders server’s Container App fails its startup probe on port 8090, check that it runs the orders image. az containerapp up can start an app on Microsoft’s placeholder image, which listens on port 80.

Did this recipe work for you?