Connect Microsoft Azure to StackSpend
Track Azure costs using the Cost Management Query API. Supports subscription-level and management group-level cost tracking.
StackSpend connects to Azure via the Cost Management Query API with service principal authentication. Get daily cost visibility, 90 days of history, cost by subscription and service, and spend forecasting. Multi-subscription supported.
Prerequisites
- An Azure subscription with billing enabled
- Access to Azure Portal with subscription owner or contributor permissions
- Azure Active Directory admin access (for app registration)
Step 1
Register an App in Azure Active Directory
Create a service principal (app registration) that StackSpend will use to authenticate and access cost data.
- 1Go to Azure Portal
- 2Navigate to Azure Active Directory → App registrations
- 3Click New registration
- 4Name:
StackSpend Cost Reader - 5Supported account types: Accounts in this organizational directory only
- 6Click Register
- 7Copy the Application (client) ID and Directory (tenant) ID - you'll need these later
Step 2
Create a Client Secret
- 1In the app registration, go to Certificates & secrets
- 2Click New client secret
- 3Description:
StackSpend Cost Access - 4Expires: Choose an appropriate expiration (e.g., 24 months)
- 5Click Add
- 6Important: Copy the Value immediately. You won't be able to see it again after leaving this page.
Step 3
Grant Cost Management Reader Role
Assign the service principal the Cost Management Reader role at the subscription or management group level.
- 1Go to Subscriptions (or Management groups if you want to track multiple subscriptions)
- 2Select your subscription (or management group)
- 3Click Access control (IAM)
- 4Click Add → Add role assignment
- 5Role: Cost Management Reader
- 6Assign access to: User, group, or service principal
- 7Search for and select your app:
StackSpend Cost Reader - 8Click Review + assign → Review + assign
Step 4
Get Your Subscription ID
- 1Go to Subscriptions in Azure Portal
- 2Select your subscription
- 3Copy the Subscription ID (format:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
Step 5
Connect in StackSpend
- 1Go to Settings → Providers in your StackSpend dashboard
- 2Click Add Provider → Select Azure
- 3Enter your credentials:
- Tenant ID: Directory (tenant) ID from Step 1
- Client ID: Application (client) ID from Step 1
- Client Secret: Client secret value from Step 2
- Subscription ID: Subscription ID from Step 4
- 4Click Test Connection to verify
- 5Once the test succeeds, click Connect
After Connecting
Once Azure is connected, StackSpend begins syncing historical cost data. The first sync typically takes a few minutes.
- Costs sync automatically every 6 hours
- Service-level and resource group-level cost breakdowns
- Location and meter category tracking