How to Enable Cost Allocation for Shared Resources in Azure

Reassign shared service costs to consuming teams for showback or chargeback

20 min readUpdated January 2025

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:

  1. Cost Allocation Rules - Redistribute costs from shared subscriptions to consuming teams based on defined percentages or metrics
  2. Tag-Based Cost Distribution - Use Azure tags to mark resource ownership and automatically split costs
  3. Consumption-Based Allocation - Allocate costs proportionally based on actual usage metrics (data ingestion, network traffic, etc.)
  4. 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

  1. Sign in to the Azure Portal
  2. Navigate to Cost Management + Billing
  3. Select your billing scope (EA enrollment or MCA billing account)
  4. Under Cost Management, select Cost allocation rules
  5. Click + Add to create a new rule

Step 2: Configure Rule Basics

  1. Name: Enter a descriptive name (e.g., "Shared-Networking-Allocation")
  2. Description: Document the allocation methodology
  3. Status: Set to Active when ready to apply
  4. Effective date: Choose when the rule should start applying

Step 3: Define Source Costs

Select which costs to redistribute:

  1. 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
  2. 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:

  1. Target type: Choose allocation method:

    • Fixed percentage - Define manual percentages
    • Tag proportionally - Distribute based on existing resource costs with matching tags
  2. Target subscriptions: Select which subscriptions should receive allocated costs

  3. 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 SubscriptionPercentageDepartment Tag
Sales-Production40%Sales
Engineering-Prod35%Engineering
Marketing-Prod25%Marketing

Step 5: Review and Create

  1. Review the configuration summary
  2. Verify percentages total 100%
  3. Check effective date
  4. Click Create

Step 6: Verify Allocation in Cost Analysis

After 24-48 hours, verify the allocation:

  1. Navigate to Cost Management > Cost analysis
  2. Set scope to a target subscription
  3. Look for cost entries labeled "Allocated cost"
  4. 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

  1. Navigate to the shared resource
  2. Select Tags from the left menu
  3. Add cost allocation tags
  4. 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

  1. In Azure Portal, navigate to Cost Management > Cost allocation rules
  2. Click + Add
  3. Configure source:
    • Source type: Tag
    • Tag name: SharedService
    • Tag value: Yes
  4. Configure target:
    • Target type: Tag proportionally
    • Target tag name: Department
  5. 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 ServiceConsumption MetricData Source
Log Analytics WorkspaceData ingestion (GB)Azure Monitor
Application GatewayRequest count, bandwidthAzure Monitor
VPN GatewayBandwidth (GB)Azure Monitor
Azure FirewallData processed (GB)Azure Monitor
Storage AccountTransactions, storage usedAzure Monitor
API ManagementAPI callsAzure 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:

TeamTotalRequestsAllocationPercentage
Engineering4,500,00045%
Sales3,000,00030%
Marketing2,500,00025%

Step 4: Create Cost Allocation Rule with Calculated Percentages

Use the calculated percentages to create a cost allocation rule:

  1. Navigate to Cost Management > Cost allocation rules
  2. Create rule with Fixed percentage method
  3. Enter the calculated percentages from step 3
  4. 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

  1. Open Power BI Desktop
  2. Select Get Data > Azure > Azure Blob Storage
  3. Enter storage account connection string
  4. Load the cost export CSV files
  5. 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

  1. Publish report to Power BI Service
  2. Configure scheduled refresh (daily or monthly)
  3. Share with finance and department managers
  4. 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:

  1. Grant Cost Management Reader role to department leads
  2. Create team-specific Cost Analysis views
  3. Publish Power BI reports filtered by department
  4. 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:

  1. Check rule status is Active
  2. Verify effective date is in the past
  3. Wait 24-48 hours for allocation processing
  4. 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:

  1. Sum all target percentages
  2. Adjust rounding (use 33.33% instead of 33% for thirds)
  3. 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:

  1. Wait 8-24 hours for tag propagation to billing data
  2. Verify tags are applied at resource level, not just resource group
  3. Check tag name capitalization (tags are case-sensitive)
  4. 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:

  1. Enable diagnostic settings on shared resources
  2. Configure metrics export to Log Analytics
  3. Wait 24 hours for data collection
  4. 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:

  1. Review allocation rule source filters
  2. Check if multiple allocation rules overlap
  3. Verify effective dates (might be allocating historical costs)
  4. 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:

  1. Verify you have Billing Administrator or Cost Management Contributor role at billing account level
  2. Cost allocation requires EA or MCA billing type
  3. 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:

  1. Set Up Cost Budgets: Create budgets for allocated costs to prevent overruns

  2. Automate Cost Exports: Schedule regular exports for detailed analysis

  3. 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
  4. 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
  5. 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

To implement tag-based cost allocation, first create a consistent tagging schema for your shared resources, including tags like CostCenter, Department, and SharedService. Next, apply these tags to the relevant resources either through the Azure Portal, CLI, or PowerShell. After tagging, navigate to Cost Management > Cost allocation rules in the Azure Portal, add a new rule, and configure the source as Tag with the appropriate tag name and value. Set the target type to Tag proportionally to allocate costs based on existing resource costs. This method ensures automatic cost distribution aligned with resource consumption.

Need Professional Help?

Our team of experts can help you implement and configure these solutions for your organization.