Azure AI Foundry Integration
Track Azure AI Foundry costs across GPT, DeepSeek, Llama, Mistral, Grok, Phi, and marketplace models using the Azure Cost Management API.
Overview
Grafient tracks your Azure AI Foundry spending by querying the Azure Cost Management API. This captures costs for all model families deployed through Azure - OpenAI GPT & o-series, DeepSeek, Llama, Mistral, Grok, Phi, Cohere, Kimi, Qwen, and more - broken down by model and token direction (input/output).
Marketplace models like Anthropic Claude deployed via Azure Marketplace are also tracked automatically through a separate SaaS billing query, merged into the same dashboard view.
Each sync queries the Azure Cost Management API, which may incur a small charge on your Azure account. See Azure pricing for details.
Prerequisites
- An Azure subscription (Pay-As-You-Go, MCA, or Enterprise Agreement) with Azure AI Foundry or Azure AI Services usage.
- Microsoft Entra ID (Azure AD) permissions to register applications.
- A Grafient account on the Free, Pro, or Ultimate plan.
Free Azure subscriptions (including free trials and Visual Studio Dev Essentials) do not support the Cost Management API. You must upgrade to a paid subscription type before connecting.
Determine Your Account Type
Not sure which account type you have? In the Azure Portal, go to Cost Management + Billing → Properties. The Account type field will show one of:
- Microsoft Online Services Program (WebDirect) → use Pay-As-You-Go in Grafient
- Microsoft Customer Agreement → use MCA in Grafient
- Enterprise Agreement → use Enterprise in Grafient
If you see Microsoft Partner Agreement (CSP), the Cost Management API is not directly accessible - see Troubleshooting below.
Step 1: Register an App in Microsoft Entra ID
- Go to the Azure Portal and navigate to Microsoft Entra ID → App registrations.
- Click New registration.
- Enter a name (e.g.
grafient-cost-reader). - Leave Supported account types as "Accounts in this organizational directory only".
- Click Register.
- On the app overview page, copy the Application (client) ID and Directory (tenant) ID - you'll need both.
Step 2: Create a Client Secret
- In your app registration, go to Certificates & secrets.
- Click New client secret.
- Add a description (e.g.
grafient) and select an expiry period. - Click Add.
- Copy the secret value immediately - it's only shown once.
Store the client secret securely. The value is only displayed once during creation. If you lose it, you'll need to create a new secret.
Step 3: Assign Permissions
The permissions you need depend on your Azure account type. Follow the section that matches your setup.
3a: Pay-As-You-Go (Subscription)
The Service Principal needs Reader access on your subscription to query cost data.
- Go to Subscriptions in the Azure Portal.
- Select the subscription containing your Azure AI resources.
- Copy the Subscription ID from the Overview page.
- Click Access control (IAM) in the sidebar.
- Click Add → Add role assignment.
- Search for and select the Reader role, then click Next.
- Click Select members, search for your app name (e.g.
grafient-cost-reader), select it, and click Select. - Click Review + assign.
For a more restrictive setup, you can use the Cost Management Reader role instead of Reader. This limits the Service Principal to only reading cost data - it cannot access any other Azure resources.
3b: Microsoft Customer Agreement (MCA)
The Service Principal needs Billing Account Reader access on your billing account.
- Go to Cost Management + Billing in the Azure Portal.
- Navigate to Properties and copy your Billing Account ID.
- Go to Access control (IAM) in the billing account sidebar.
- Click Add → Add role assignment.
- Search for and select the Billing Account Reader role, then click Next.
- Click Select members, search for your app name (e.g.
grafient-cost-reader), select it, and click Select. - Click Review + assign.
3c: Enterprise Agreement (EA)
The Service Principal needs Enrollment Reader access on your billing account.
- Go to Cost Management + Billing in the Azure Portal.
- Navigate to Properties and copy your Billing Account ID (enrollment number).
- Go to Access control (IAM) in the billing account sidebar.
- Click Add → Add role assignment.
- Search for and select the Enrollment Reader role, then click Next.
- Click Select members, search for your app name (e.g.
grafient-cost-reader), select it, and click Select. - Click Review + assign.
Step 4: Add the Integration in Grafient
- In Grafient, navigate to Integrations in the sidebar.
- Click Add Integration.
- Select Azure AI Foundry as the provider.
- Select your Account Type (Pay-As-You-Go, MCA, or Enterprise).
- Enter the Tenant ID from Step 1.
- Enter the Client ID from Step 1.
- Enter the Client Secret from Step 2.
- For Pay-As-You-Go: enter the Subscription ID from Step 3a. For MCA or Enterprise: enter the Billing Account ID from Step 3b/3c.
- Optionally add a label (e.g.
Production - Azure AI). - Click Add Integration to save.
What Happens Next
Once connected, Grafient will:
- Validate your credentials by authenticating with Microsoft Entra ID and making a test query to the Cost Management API.
- Backfill historical costs - up to 30 days on Free, or 365 days on Pro/Ultimate.
- Sync daily - an automated sync pulls the latest Azure AI costs across all model families.
Costs appear on the Dashboard grouped by model (e.g. GPT-4o, DeepSeek R1, Llama 3.3 70B, Mistral Large 3). Both first-party Foundry Models and Marketplace models are included.
Data Collected
| Data Point | Description |
|---|---|
| Daily cost (USD) | Total Azure AI spend per day, broken down by model |
| Model breakdown | Cost per model across all families (OpenAI, DeepSeek, Llama, Mistral, Grok, Phi, etc.) |
| Token direction | Costs split by input and output tokens where available |
| Marketplace models | SaaS-billed models (e.g. Anthropic Claude) tracked via separate billing query |
Data Freshness
Azure Cost Management data has a 24–48 hour delay. Cost data from today will typically appear in 1–2 days. This is an Azure platform limitation - the billing pipeline does not process in real time.
The daily sync captures the latest available data. For the most current view, click Force Sync on your integration card.
Troubleshooting
"AADSTS7000215: Invalid client secret"
The client secret you entered is incorrect or has expired. Create a new client secret in your app registration (Step 2) and update the integration.
"AuthorizationFailed" error
The Service Principal doesn't have the required role. Make sure you've completed the correct Step 3 sub-section for your account type:
- Pay-As-You-Go: Reader or Cost Management Reader on the subscription.
- MCA: Billing Account Reader on the billing account.
- EA: Enrollment Reader on the billing account.
"BillingAccountNotFound" or "404" error
The Billing Account ID you entered doesn't match your Azure account. Go to Cost Management + Billing → Properties in the Azure Portal and verify the Billing Account ID. Make sure you selected the correct account type (MCA vs EA) in Grafient.
"IndirectCostDisabled" or free subscription error
Free Azure subscriptions (free trials, Visual Studio Dev Essentials, Azure for Students) do not support the Cost Management API. You must upgrade to a Pay-As-You-Go, MCA, or Enterprise subscription.
CSP (Cloud Solution Provider) subscriptions
Azure subscriptions managed by a Cloud Solution Provider (CSP/Microsoft Partner Agreement) do not support direct Cost Management API access. Cost data for CSP subscriptions is managed by the partner. Contact your CSP provider for billing data.
No cost data after sync
- Check for Azure AI usage: If there has been no AI model usage, there will be no cost data. Verify in the Azure Portal under your AI resource → Metrics.
- Data delay: Due to the 24–48 hour processing delay, recent costs may not have arrived yet.
- Correct scope: Make sure the Subscription ID or Billing Account ID matches where your Azure AI resources are deployed.
- Try Force Sync: Click the refresh icon on your integration card to trigger a manual sync.
Cost data looks incomplete
- Marketplace models: Models deployed via Azure Marketplace (e.g. Anthropic Claude) are billed under SaaS. Grafient queries both billing tracks, but if you only see first-party models, the marketplace query may need a moment to populate.
- Data delay: Due to the 24–48 hour processing delay, yesterday's costs may not have arrived yet.
- New model families: Grafient automatically captures all models billed under Azure AI Foundry. If a brand-new model family doesn't appear, it may use a different Azure service name - contact support.