How to Enable Cost Allocation for Shared Resources in Azure
Shared services like networking, monitoring, and security tools often serve multiple teams or business units, but their costs typically land in a single subscription or resource group. This guide shows you how to fairly allocate these shared costs to consuming teams using Azure Cost Management's cost allocation rules, tags, and proportional distribution methods for accurate showback and chargeback.
Overview
In enterprise Azure environments, centralized shared services create a challenge for cost accountability. When the IT infrastructure team manages a shared VPN gateway serving five business units, how do you fairly split the $500 monthly cost? When a shared Log Analytics workspace collects data from 50 different applications, how do you attribute costs to the right teams?
Azure Cost Management provides several mechanisms for solving this problem:
- Cost Allocation Rules - Redistribute costs from shared subscriptions to consuming teams based on defined percentages or metrics
- Tag-Based Cost Distribution - Use Azure tags to mark resource ownership and automatically split costs
- Consumption-Based Allocation - Allocate costs proportionally based on actual usage metrics (data ingestion, network traffic, etc.)
- Custom Budget and Chargeback Reports - Create automated reports showing allocated costs for each team
This guide covers all four approaches with detailed implementation steps.
Prerequisites
Before you begin, ensure you have:
- Billing Administrator or Cost Management Contributor role on the billing account
- Owner or Contributor role on subscriptions containing shared resources
- Azure CLI installed and authenticated (
az login) - PowerShell with Az module installed (for advanced automation)
- Active Enterprise Agreement (EA) or Microsoft Customer Agreement (MCA) - Cost Allocation Rules require EA or MCA
- Clear understanding of your shared resources and the teams that consume them
- Established cost allocation methodology (fixed percentage, usage-based, or hybrid)
Verify Your Access
# Check your cost management permissions
az role assignment list \
--assignee $(az account show --query user.name -o tsv) \
--query "[?contains(roleDefinitionName, 'Cost')].{Role:roleDefinitionName, Scope:scope}" -o table
# Verify billing account access
az billing account list -o table
Understanding Cost Allocation Methods
Before implementing cost allocation, choose the right methodology for your organization:
1. Fixed Percentage Allocation
Use when: Consumption patterns are stable and predictable.
Example: A shared ExpressRoute circuit serves three business units with roughly equal usage:
- Business Unit A: 33%
- Business Unit B: 33%
- Business Unit C: 34%
2. Usage-Based Allocation
Use when: Actual consumption metrics are available and vary significantly.
Example: Shared Log Analytics costs allocated by data ingestion volume:
- Team 1: 45% (ingests 4.5GB/day)
- Team 2: 30% (ingests 3.0GB/day)
- Team 3: 25% (ingests 2.5GB/day)
3. Hybrid Allocation
Use when: Some costs are fixed, others variable.
Example: Shared Application Gateway:
- Base infrastructure cost: Split evenly (33% each)
- Data processing costs: Split by traffic volume
Method 1: Create Cost Allocation Rules (Azure Portal)
Cost Allocation Rules are available for Enterprise Agreement (EA) and Microsoft Customer Agreement (MCA) customers.
Step 1: Navigate to Cost Allocation Rules
- Sign in to the Azure Portal
- Navigate to Cost Management + Billing
- Select your billing scope (EA enrollment or MCA billing account)
- Under Cost Management, select Cost allocation rules
- Click + Add to create a new rule
Step 2: Configure Rule Basics
- Name: Enter a descriptive name (e.g., "Shared-Networking-Allocation")
- Description: Document the allocation methodology
- Status: Set to Active when ready to apply
- Effective date: Choose when the rule should start applying
Step 3: Define Source Costs
Select which costs to redistribute:
-
Source type: Choose one:
- Subscription - Allocate costs from an entire subscription
- Resource group - Allocate costs from specific resource groups
- Tag - Allocate costs from resources with specific tags
-
Select sources: Choose the specific subscriptions, resource groups, or tag values
Example: Select subscription "Shared-Infrastructure" containing all shared networking resources.
Step 4: Define Allocation Targets
Specify where to redistribute costs:
-
Target type: Choose allocation method:
- Fixed percentage - Define manual percentages
- Tag proportionally - Distribute based on existing resource costs with matching tags
-
Target subscriptions: Select which subscriptions should receive allocated costs
-
Allocation percentages (if using fixed percentage):
- Add each target subscription
- Enter percentage (must total 100%)
- Add cost center or department tags for reporting
Example Configuration:
| Target Subscription | Percentage | Department Tag |
|---|---|---|
| Sales-Production | 40% | Sales |
| Engineering-Prod | 35% | Engineering |
| Marketing-Prod | 25% | Marketing |
Step 5: Review and Create
- Review the configuration summary
- Verify percentages total 100%
- Check effective date
- Click Create
Step 6: Verify Allocation in Cost Analysis
After 24-48 hours, verify the allocation:
- Navigate to Cost Management > Cost analysis
- Set scope to a target subscription
- Look for cost entries labeled "Allocated cost"
- Group by Tag or Resource group to see original vs allocated costs
Method 2: Implement Tag-Based Cost Allocation
Use Azure tags to automatically split shared resource costs across consuming teams.
Step 1: Design Your Tagging Strategy
Create a consistent tagging schema:
Standard Tags:
- CostCenter: "CC-1234" # Financial cost center
- Department: "Engineering" # Business unit
- Environment: "Production" # Environment type
- Project: "ProjectX" # Project or application
- Owner: "team-platform@company" # Responsible team
- SharedService: "Yes" # Marks shared resources
- AllocationMethod: "Proportional" # How to split costs
Step 2: Apply Tags to Shared Resources
Option A: Azure Portal
- Navigate to the shared resource
- Select Tags from the left menu
- Add cost allocation tags
- Click Apply
Option B: Azure CLI
# Tag a shared resource
az resource tag \
--resource-group "shared-infra-rg" \
--name "shared-app-gateway" \
--resource-type "Microsoft.Network/applicationGateways" \
--tags \
CostCenter="Shared" \
Department="IT-Infrastructure" \
SharedService="Yes" \
AllocationMethod="Proportional"
# Tag all resources in a resource group
az group update \
--name "shared-infra-rg" \
--tags \
CostCenter="Shared" \
Department="IT-Infrastructure" \
SharedService="Yes"
Option C: PowerShell
# Tag a shared Application Gateway
$tags = @{
"CostCenter" = "Shared"
"Department" = "IT-Infrastructure"
"SharedService" = "Yes"
"AllocationMethod" = "Proportional"
}
$resource = Get-AzResource `
-ResourceGroupName "shared-infra-rg" `
-Name "shared-app-gateway"
Update-AzTag -ResourceId $resource.Id -Tag $tags -Operation Merge
Step 3: Tag Consuming Resources
Tag resources that consume the shared service:
# Tag application resources that use shared services
az resource tag \
--resource-group "sales-prod-rg" \
--name "sales-web-app" \
--resource-type "Microsoft.Web/sites" \
--tags \
CostCenter="CC-5001" \
Department="Sales" \
ConsumesSharedService="Yes" \
SharedServiceConsumption="High"
Step 4: Create Cost Allocation Rule Using Tags
- In Azure Portal, navigate to Cost Management > Cost allocation rules
- Click + Add
- Configure source:
- Source type: Tag
- Tag name:
SharedService - Tag value:
Yes
- Configure target:
- Target type: Tag proportionally
- Target tag name:
Department
- This allocates shared service costs proportionally across all departments based on their existing resource costs
Step 5: Enforce Tagging with Azure Policy
Prevent untagged resources using Azure Policy:
# Assign policy to require cost allocation tags
az policy assignment create \
--name "require-cost-tags" \
--display-name "Require Cost Allocation Tags" \
--scope "/subscriptions/$(az account show --query id -o tsv)" \
--policy "$(az policy definition list --query "[?displayName=='Require a tag on resources'].id" -o tsv)" \
--params '{
"tagName": {
"value": "CostCenter"
}
}'
Azure Policy Definition (JSON):
{
"properties": {
"displayName": "Require Cost Allocation Tags",
"policyType": "Custom",
"mode": "Indexed",
"description": "Require CostCenter and Department tags on all resources",
"parameters": {},
"policyRule": {
"if": {
"anyOf": [
{
"field": "tags['CostCenter']",
"exists": "false"
},
{
"field": "tags['Department']",
"exists": "false"
}
]
},
"then": {
"effect": "deny"
}
}
}
}
Method 3: Usage-Based Allocation with Azure Monitor Metrics
Allocate costs based on actual consumption metrics like data ingestion, bandwidth, or request volume.
Step 1: Identify Consumption Metrics
Determine which metrics represent resource consumption:
Common Metrics for Shared Services:
| Shared Service | Consumption Metric | Data Source |
|---|---|---|
| Log Analytics Workspace | Data ingestion (GB) | Azure Monitor |
| Application Gateway | Request count, bandwidth | Azure Monitor |
| VPN Gateway | Bandwidth (GB) | Azure Monitor |
| Azure Firewall | Data processed (GB) | Azure Monitor |
| Storage Account | Transactions, storage used | Azure Monitor |
| API Management | API calls | Azure Monitor |
Step 2: Export Consumption Metrics to Storage
# Create diagnostic settings for shared Application Gateway
az monitor diagnostic-settings create \
--name "appgw-metrics-export" \
--resource "/subscriptions/SUB-ID/resourceGroups/shared-rg/providers/Microsoft.Network/applicationGateways/shared-appgw" \
--workspace "/subscriptions/SUB-ID/resourceGroups/monitoring-rg/providers/Microsoft.OperationalInsights/workspaces/central-law" \
--metrics '[
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"days": 30,
"enabled": true
}
}
]'
Step 3: Calculate Consumption Percentages
Use Log Analytics queries to calculate each team's consumption:
// Calculate Application Gateway traffic by backend pool (representing different teams)
AzureMetrics
| where ResourceProvider == "MICROSOFT.NETWORK"
| where ResourceId contains "applicationGateways/shared-appgw"
| where MetricName == "BackendResponseStatus"
| extend BackendPool = tostring(split(BackendPoolName, "/")[1])
| extend Team = case(
BackendPool contains "sales", "Sales",
BackendPool contains "eng", "Engineering",
BackendPool contains "marketing", "Marketing",
"Unknown"
)
| summarize TotalRequests = sum(Total) by Team
| extend Percentage = round(100.0 * TotalRequests / toint(sum(TotalRequests)), 2)
| project Team, TotalRequests, AllocationPercentage = strcat(Percentage, "%")
Example Output:
| Team | TotalRequests | AllocationPercentage |
|---|---|---|
| Engineering | 4,500,000 | 45% |
| Sales | 3,000,000 | 30% |
| Marketing | 2,500,000 | 25% |
Step 4: Create Cost Allocation Rule with Calculated Percentages
Use the calculated percentages to create a cost allocation rule:
- Navigate to Cost Management > Cost allocation rules
- Create rule with Fixed percentage method
- Enter the calculated percentages from step 3
- Set rule to recalculate monthly based on updated metrics
Step 5: Automate Monthly Recalculation
Use Azure Automation to update allocation percentages monthly:
# Azure Automation Runbook: Update-SharedCostAllocation.ps1
param(
[Parameter(Mandatory=$true)]
[string]$BillingAccountId,
[Parameter(Mandatory=$true)]
[string]$AllocationRuleName
)
# Connect using managed identity
Connect-AzAccount -Identity
# Query Log Analytics for consumption data
$workspaceId = "/subscriptions/.../workspaces/central-law"
$query = @"
AzureMetrics
| where TimeGenerated > ago(30d)
| where ResourceProvider == "MICROSOFT.NETWORK"
| where MetricName == "BackendResponseStatus"
| extend Team = extract("(sales|eng|marketing)", 1, BackendPoolName)
| summarize Requests = sum(Total) by Team
| extend Percentage = round(100.0 * Requests / toint(sum(Requests)), 2)
"@
$results = Invoke-AzOperationalInsightsQuery -WorkspaceId $workspaceId -Query $query
# Update cost allocation rule
$percentages = @{}
foreach ($row in $results.Results) {
$percentages[$row.Team] = $row.Percentage
}
# Update allocation rule (API call)
# Note: As of 2025, there's no native cmdlet, use REST API
$uri = "https://management.azure.com$BillingAccountId/providers/Microsoft.CostManagement/costAllocationRules/$($AllocationRuleName)?api-version=2020-03-01-preview"
$body = @{
properties = @{
details = @{
sourceResources = @(...)
targetResources = @(
foreach ($team in $percentages.Keys) {
@{
name = "$team-Subscription"
percentage = $percentages[$team]
}
}
)
}
}
} | ConvertTo-Json -Depth 10
Invoke-AzRestMethod -Path $uri -Method PUT -Payload $body
Method 4: Create Chargeback Reports with Power BI
Build automated reports showing allocated costs for each team.
Step 1: Export Cost Data to Storage
# Create cost export with allocation data
az costmanagement export create \
--name "monthly-chargeback-export" \
--type "AmortizedCost" \
--scope "/providers/Microsoft.Billing/billingAccounts/YOUR-BILLING-ACCOUNT" \
--storage-account-id "/subscriptions/SUB-ID/resourceGroups/rg/providers/Microsoft.Storage/storageAccounts/costdata" \
--storage-container "chargeback" \
--timeframe "MonthToDate" \
--recurrence "Monthly" \
--recurrence-period-from "2025-01-01" \
--recurrence-period-to "2025-12-31" \
--schedule-status "Active" \
--format "Csv"
Step 2: Connect Power BI to Cost Data
- Open Power BI Desktop
- Select Get Data > Azure > Azure Blob Storage
- Enter storage account connection string
- Load the cost export CSV files
- Transform data to include allocation columns
Step 3: Create Chargeback Report Dashboard
Build visualizations showing:
- Total allocated costs by department
- Shared service costs vs direct costs
- Cost trends over time
- Top shared services by cost
- Allocation percentage breakdown
Step 4: Publish and Schedule Refresh
- Publish report to Power BI Service
- Configure scheduled refresh (daily or monthly)
- Share with finance and department managers
- Set up data alerts for cost threshold breaches
Best Practices
1. Start Simple, Then Iterate
Begin with fixed percentage allocations, then move to usage-based as you gather more data:
Phase 1 (Month 1-3): Fixed percentages based on estimated usage Phase 2 (Month 4-6): Tag-based allocation with quarterly reviews Phase 3 (Month 7+): Automated usage-based allocation with monthly updates
2. Document Allocation Methodology
Create a shared document explaining:
- Which resources are considered "shared"
- Allocation formulas and percentages
- Data sources for usage metrics
- Update frequency
- Dispute resolution process
3. Implement Gradual Rollout
Don't charge back all costs immediately:
Month 1: Showback only (informational reports) Month 2-3: Soft chargeback (tracked but not invoiced) Month 4+: Hard chargeback (actual budget transfers)
4. Review Allocations Quarterly
Schedule quarterly reviews to adjust allocation percentages:
# Create quarterly reminder to review allocations
# Use Azure Logic App or Azure Automation schedule
5. Provide Self-Service Cost Visibility
Give teams access to their allocated costs:
- Grant Cost Management Reader role to department leads
- Create team-specific Cost Analysis views
- Publish Power BI reports filtered by department
- Set up budget alerts for each cost center
6. Handle Edge Cases
Define policies for:
- New teams: How to allocate when a new team starts using shared services
- Departing teams: What happens to allocation percentages when a team stops using a service
- Seasonal variations: How to handle predictable spikes (e.g., retail during holidays)
- Minimum allocations: Whether to set a minimum percentage (e.g., 5%) for all consuming teams
7. Exclude Non-Allocable Costs
Some costs shouldn't be allocated:
- One-time setup fees (allocate upfront or amortize)
- Reserved instance purchases (handle separately with RI sharing)
- Support plans (often enterprise-wide, not team-specific)
- Licensing (depends on licensing model)
Troubleshooting
Issue: Cost Allocation Rule Not Appearing in Cost Analysis
Symptoms: Created allocation rule but don't see allocated costs in reports
Solution:
- Check rule status is Active
- Verify effective date is in the past
- Wait 24-48 hours for allocation processing
- Ensure you have correct billing scope selected
# Check allocation rule status
az rest --method GET \
--uri "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/YOUR-BILLING-ACCOUNT/providers/Microsoft.CostManagement/costAllocationRules/YOUR-RULE-NAME?api-version=2020-03-01-preview"
Issue: Allocation Percentages Don't Total 100%
Symptoms: Error when creating allocation rule about percentages
Solution:
- Sum all target percentages
- Adjust rounding (use 33.33% instead of 33% for thirds)
- Add remainder to largest consumer
# Python script to ensure percentages total 100%
percentages = {"TeamA": 33.33, "TeamB": 33.33, "TeamC": 33.33}
total = sum(percentages.values())
difference = 100.0 - total
# Add difference to largest
largest_team = max(percentages, key=percentages.get)
percentages[largest_team] += difference
print(f"Adjusted percentages: {percentages}")
# Output: Adjusted percentages: {'TeamA': 33.33, 'TeamB': 33.33, 'TeamC': 33.34}
Issue: Tags Not Appearing in Cost Analysis
Symptoms: Applied tags to resources but can't filter by them in Cost Analysis
Solution:
- Wait 8-24 hours for tag propagation to billing data
- Verify tags are applied at resource level, not just resource group
- Check tag name capitalization (tags are case-sensitive)
- Use Cost analysis > View > Column > Add tags to make tags visible
# Verify tags on resource
az resource show \
--ids "/subscriptions/SUB-ID/resourceGroups/rg/providers/Microsoft.Network/applicationGateways/appgw" \
--query tags
Issue: Consumption Metrics Not Available
Symptoms: Can't find usage data to calculate proportional allocation
Solution:
- Enable diagnostic settings on shared resources
- Configure metrics export to Log Analytics
- Wait 24 hours for data collection
- Verify Log Analytics workspace has data retention enabled
# Check diagnostic settings
az monitor diagnostic-settings list \
--resource "/subscriptions/SUB-ID/resourceGroups/rg/providers/Microsoft.Network/applicationGateways/appgw"
# Query for available metrics
az monitor metrics list-definitions \
--resource "/subscriptions/SUB-ID/resourceGroups/rg/providers/Microsoft.Network/applicationGateways/appgw"
Issue: Allocated Costs Higher Than Expected
Symptoms: Target subscription shows unexpectedly high allocated costs
Solution:
- Review allocation rule source filters
- Check if multiple allocation rules overlap
- Verify effective dates (might be allocating historical costs)
- Review source subscription actual costs
# List all active allocation rules
az rest --method GET \
--uri "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/YOUR-BILLING-ACCOUNT/providers/Microsoft.CostManagement/costAllocationRules?api-version=2020-03-01-preview" \
| jq '.value[] | select(.properties.status=="Active") | {name: .name, source: .properties.details.sourceResources, targets: .properties.details.targetResources}'
Issue: Cannot Create Allocation Rule (Access Denied)
Symptoms: Error message about insufficient permissions
Solution:
- Verify you have Billing Administrator or Cost Management Contributor role at billing account level
- Cost allocation requires EA or MCA billing type
- CSP and PAYG subscriptions don't support cost allocation rules
# Check your billing account type
az billing account list --query '[].{Name:name, Type:agreementType}' -o table
# Expected output for supported types:
# Name Type
# 12345678 EnterpriseAgreement
# or
# abcd-efgh-1234-5678 MicrosoftCustomerAgreement
Next Steps
After implementing cost allocation for shared resources:
-
Set Up Cost Budgets: Create budgets for allocated costs to prevent overruns
-
Automate Cost Exports: Schedule regular exports for detailed analysis
-
Build FinOps Practice: Establish cloud financial management processes
- Monthly cost review meetings with department leads
- Quarterly allocation methodology reviews
- Annual budget planning with allocated costs
- Cost optimization initiatives based on allocation data
-
Implement Reservation Sharing: Optimize Reserved Instance and Savings Plan allocation
- Configure RI benefit sharing across subscriptions
- Track reservation utilization by department
- Allocate reservation savings proportionally
-
Create Cost Optimization Feedback Loop: Use allocation data to drive optimization
- Identify teams with highest shared service consumption
- Collaborate on optimization opportunities
- Track cost reduction initiatives by department
- Celebrate cost savings wins
Related Resources
Frequently Asked Questions
Find answers to common questions
Need Professional Help?
Our team of experts can help you implement and configure these solutions for your organization.