#!/usr/bin/env bash # STATUS: UNVERIFIED — no cloud credentials in this atlas; snippet follows official docs verbatim-ish # Source: https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry (retrieved 2026-09-18) # No secrets in this file: key read from ANTHROPIC_FOUNDRY_API_KEY; resource name from ANTHROPIC_FOUNDRY_RESOURCE. set -eo pipefail RESOURCE="${ANTHROPIC_FOUNDRY_RESOURCE:?set ANTHROPIC_FOUNDRY_RESOURCE}" if [ -n "${ANTHROPIC_FOUNDRY_API_KEY:-}" ]; then AUTH_HEADER="api-key: ${ANTHROPIC_FOUNDRY_API_KEY}" # x-api-key is accepted too else # Microsoft Entra ID token (requires Azure CLI login and Entra auth enabled on the resource) AUTH_HEADER="Authorization: Bearer $(az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv)" fi curl -sS "https://${RESOURCE}.services.ai.azure.com/anthropic/v1/messages" \ -H "content-type: application/json" \ -H "${AUTH_HEADER}" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "claude-haiku-4-5", "max_tokens": 8, "messages": [{"role": "user", "content": "Reply with OK."}] }' echo # Debugging: quote both `request-id` and `apim-request-id` response headers to support (curl -i).