Skip to main content

Monitor Azure subscription resources with cost and usage tracking and reports

Workflow preview

Workflow preview
100%
Monitor Azure subscription resources with cost and usage tracking and reports preview
Open on n8n.io

1. Workflow Overview

Monitor Azure subscription resources with cost and usage tracking Template Name Monitor Azure subscription resources with cost and usage tracking Description Automatically connect to your Azure sub...

Best for

  • DevOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.manualtrigger, n8n-nodes-base.set, n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.if, n8n-nodes-base.spreadsheetfile, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by kartik ramachandran.

Original n8n.io source

1.1 Workflow description

Title
Monitor Azure subscription resources with cost and usage tracking and reports
Workflow name
Monitor Azure subscription resources with cost and usage tracking and reports

Monitor Azure subscription resources with cost and usage tracking

Template Name

Monitor Azure subscription resources with cost and usage tracking

Description

Automatically connect to your Azure subscription to retrieve all resources and track costs. Generates formatted reports with total spending, top expensive resources, and cost breakdown by type.

Who's it for

DevOps Engineers, Cloud Architects, Finance Teams, IT Managers, and organizations implementing FinOps practices.

How it works

  1. Authentication: OAuth2 Service Principal with Azure
  2. Resource Discovery: Queries Azure Resource Graph API
  3. Cost Retrieval: Fetches data from Cost Management API
  4. Data Processing: Merges resources with costs
  5. Report Generation: Creates text/HTML reports
  6. Output: Excel export, Power BI streaming, or API/Webhook response

Set up steps

Prerequisites

  • Azure Subscription with appropriate permissions
  • Azure Service Principal with Reader and Cost Management Reader roles

Setup

1. Create Azure Service Principal

Azure CLI:

az ad sp create-for-rbac --name "n8n-cost-monitor" --role "Reader" --scopes /subscriptions/{sub-id}
az role assignment create --assignee {client-id} --role "Cost Management Reader" --scope /subscriptions/{sub-id}

Or use Azure Portal: Azure AD → App registrations → New registration → Assign roles

2. Configure n8n OAuth2 Credential

  • Credentials → OAuth2 API
  • Grant Type: Client Credentials
  • Access Token URL: https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token
  • Scope: https://management.azure.com/.default

3. Update Workflow Configuration

  • Open "Set Configuration" node
  • Update subscriptionId and tenantId
  • Set timeRange (see options below)
  • Assign OAuth2 credential to HTTP nodes

Time Range Options:

  • currentMonth - Current billing month (default)
  • lastMonth - Previous full month
  • last30Days - Last 30 days
  • last90Days - Last 90 days (3 months)
  • last6Months - Last 6 months
  • yearToDate - From Jan 1 to today
  • lastYear - Full previous year (365 days)
  • custom - Manually set startDate and endDate

4. Enable Output Options (Optional)

  • Excel: Enable "Export to Excel" node for .xlsx downloads
  • Power BI: Enable "Prepare Power BI Data" and "Send to Power BI" nodes with Push URL
  • API/Webhook: Enable "Respond to Webhook" node and change trigger to Webhook

5. Schedule (Optional)

Replace Manual Trigger with Schedule Trigger (daily: 0 9 * * *)

Requirements

Azure Requirements

  • Active Azure subscription
  • Permissions to create Service Principal
  • Permissions to assign Reader and Cost Management Reader roles

n8n Requirements

  • n8n instance (cloud or self-hosted version 1.0+)
  • Ability to create OAuth2 credentials

Optional Requirements

  • Slack workspace (for Slack notifications)
  • Email service credentials (for email reports)
  • Database instance (for data storage)

How to customize the workflow

Enable Output Options

The workflow includes three disabled output nodes. To enable them:

  1. Click on the node (Excel Export, Power BI, or Webhook Response)
  2. Click the three dots menu → Enable
  3. Configure the node settings as needed

Excel Export Configuration

The Excel export node is pre-configured but disabled. To use it:

// Already configured to export:
- All resources with their costs
- Formatted as Excel (.xlsx)
- Filename includes current date
- Headers included automatically

To customize:

  • Change filename pattern in the node settings
  • Add/remove columns by modifying the data mapping
  • Export to CSV instead by changing the file extension

Power BI Integration

Step 1: Create Power BI Streaming Dataset

  1. Go to Power BI workspace
  2. Create New → Streaming dataset → API
  3. Define schema:
{
 "summary": {
 "totalCost": "string",
 "resourceCount": "number",
 "period": "string"
 },
 "resources": [
 {
 "resourceName": "string",
 "resourceType": "string",
 "cost": "string"
 }
 ],
 "timestamp": "datetime",
 "reportType": "string"
}
  1. Copy the Push URL

Step 2: Configure n8n Workflow

  1. Enable "Prepare Power BI Data" node
  2. Enable "Send to Power BI" node
  3. Update the URL in "Send to Power BI" node with your Push URL
  4. Test the workflow

Step 3: Create Power BI Dashboard

  • Create visualizations from the streaming dataset
  • Add cards for Total Cost, Resource Count
  • Add tables for Top Resources
  • Add charts for Cost by Type

API Response / Webhook Mode

To use the workflow as an API endpoint:

Step 1: Change Trigger

  1. Delete "Manual Trigger" node
  2. Add "Webhook" trigger node
  3. Choose GET or POST method
  4. Copy the webhook URL

Step 2: Enable Response Node

  • Azure subscription with Service Principal permissions
  • n8n 1.0+ (cloud or self-hosted)
  • OAuth2 credentials capability import requests response = requests.get("https://your-n8n-instance.com/webhook/azure-cost-report") data = response.json() print(f"Total Cost: ${data['data']['totalCost']}")

**Response Format:**

```json
{
 "status": "success",
 "data": {

### Enable Output Options

Right-click disabled nodes → Enable → Configure settings

### Filter Resources

Modify query in "Query Azure Resources" node:

```kusto
Resources
| where resourceGroup contains 'production'
| project name, type, location, resourceGroup, tags, id

Change Time Range

Set timeRange in "Set Configuration" node:

timeRange: "last30Days" // Last 30 days
timeRange: "last90Days" // Last quarter
timeRange: "last6Months" // Last 6 months
timeRange: "yearToDate" // YTD from Jan 1
timeRange: "lastYear" // Previous 365 days
timeRange: "custom" // Use custom dates

For custom periods, set timeRange to "custom" and manually update:

startDate: "2026-01-01"
endDate: "2026-01-31"

Add Cost Alerts

{{ parseFloat($json.summary.totalCost) > 1000 }}

Troubleshooting

Common Issues

"Authentication failed"

  • Verify your Tenant ID is correct
  • Check that Client ID and Secret are valid
  • Ensure the Service Principal has the required roles

"No resources returned"

  • Verify the Subscription ID is correct
  • Check that Service Principal has Reader role
  • Try running the query in Azure Resource Graph Explorer first

"No cost data available"

  • Cost data may take 24-48 hours to appear
  • VeAdjust Cost Period

In "Set Configuration" node:

// Last 7 days
startDate: {{ $now.minus({days: 7}).format('yyyy-MM-dd') }}
endDate: {{ $now.format('yyyy-MM-dd') }}

Add Cost Alerts

Add IF node after "Format Report":

{{ parseFloat($json.summary.totalCost) > 1000 }2. **Microsoft.Sql/servers/databases** - 3 resources - $345.67
...

---
_Generated by n8n on 1/19/2026, 10:30:00 AM_

HTML Report Format

Includes styled HTML with:

  • Professional color scheme (Azure blue #0078D4)
  • Responsive tables
  • Summary cards with highlighted metrics
  • Sortable columns
  • Even row highlighting for readability

Excel Export Columns

Column Type Description
resourceName String Name of the Azure resource
resourceType String Full resource type (e.g., Microsoft.Compute/virtualMachines)
resourceGroup String Resource group name
location String Azure region (e.g., eastus, westus2)
sku Object SKU information (name, tier)
tags Object All resource tags
cost Number Total cost for the period
costDetails Array Detailed daily cost breakdown

Power BI Data Schema

Recommended Power BI measures:

Total Cost = SUM('CostData'[cost])
Avg Cost Per Resource = DIVIDE([Total Cost], COUNT('CostData'[resourceName]))
Cost Variance = [Total Cost] - CALCULATE([Total Cost], DATEADD('CostData'[timestamp], -1, MONTH))
Top 5 Expensive Resources = TOPN(5, 'CostData', 'CostData'[cost], DESC)

Integration Examples

Python Integration

import requests
import pandas as pd

# Call the n8n webhook
url = "https://your-n8n-instance.com/webhook/azure-cost-report"
response = requests.get(url)
data = response.json()

# Convert to DataFrame
resources_df = pd.DataFrame(data['data']['summary']['allResources'])

# Analyze costs
print(f"Total Cost: ${data['data']['totalCost']}")
print(f"Most expensive resource: {resources_df.iloc[0]['resourceName']}")

# Export to local Excel
resources_df.to_excel('azure_costs.xlsx', index=False)

PowerShell Integration

# Call the webhook
$url = "https://your-n8n-instance.com/webhook/azure-cost-report"
$response = Invoke-RestMethod -Uri $url -Method Get

# Display summary
Write-Host "Total Cost: $($response.data.totalCost)" -ForegroundColor Green
Write-Host "Resource Count: $($response.data.resourceCount)"

# Export to CSV
$response.data.summary.allResources | 
 Export-Csv -Path "azure-costs.csv" -NoTypeInformation

# Send alert if cost exceeds threshold
if ([decimal]$response.data.totalCost -gt 1000) {
 Send-MailMessage -To "[email protected]" `
 -Subject "Azure Cost Alert" `
 -Body "Current costs: $($response.data.totalCost)" `
 -SmtpServer "smtp.company.com"
}

JavaScript/Node.js Integration

const axios = require('axios');

**"Authentication failed"**: Verify Tenant ID, Client ID, Secret, and Service Principal roles

**"No resources returned"**: Check Subscription ID and Reader role assignment

**"No cost data"**: Cost data takes 24-48 hours to appear. Verify Cost Management Reader role.

**"Rate limiting (429)"**: Add Wait node between API calls or reduce query frequency

## Resources

- [Azure Resource Graph](https://learn.microsoft.com/azure/governance/resource-graph/)
- [Cost Management API](https://learn.microsoft.com/rest/api/cost-management/)
- [n8n Documentation](https://docs.n8n.io/---

**Category**: Cloud Management, DevOps, FinOps 
**Difficulty**: Intermediate 
**Setup Time**: 10-15 minutes 
**n8n Version**: 1.0+

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note - Config

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note - Data Collection

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note - Processing

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note - Outputs

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Manual Trigger

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 7 - Set Configuration

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 8 - Query Azure Resources

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 9 - Get Cost Data

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 10 - Merge and Process Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 11 - Format Report

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Check If Data Exists

Type / Role
n8n-nodes-base.if - if
Config choices
Version 1

Block 13 - Output Report

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 14 - Export to Excel

Type / Role
n8n-nodes-base.spreadsheetFile - spreadsheetFile
Config choices
Version 1

Block 15 - Prepare Power BI Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 16 - Send to Power BI

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 17 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 18 - No Data Found

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

3. Summary Table

Workflow Monitor Azure subscription resources with cost and usage tracking and reports
Complexity advanced
Nodes 18
Categories DevOps
Author kartik ramachandran
Published 18 Jan 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/12802/12802.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Monitor Azure subscription resources with cost and usage tracking and reports do?

Monitor Azure subscription resources with cost and usage tracking Template Name Monitor Azure subscription resources with cost and usage tracking Description Automatically connect to your Azure sub...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your DevOps use case.