Ojasa Mirai

Ojasa Mirai

Cloud

Loading...

Learning Level

🟢 Beginner🔵 Advanced
🔧 Azure Account Setup⚙️ Azure Compute Overview🖥️ Virtual Machines🎯 App Service Deployment⚡ Azure Functions📁 Blob Storage🗄️ Azure SQL Database📊 Cosmos DB📊 Azure Monitoring🔑 Azure Identity & Access📈 Azure Scaling & Load Balancing🐳 Azure Containers & AKS🎯 Azure Static Web Apps💰 Azure Cost Optimization
Cloud/Azure Deployment/Azure Cost Optimization

💰 Azure Cost Optimization - Advanced

Cost Attribution and Showback

from azure.costmanagement import CostManagementClient

def calculate_department_costs(subscription_id, department_tag):
  client = CostManagementClient(credential)
  
  query = {
    "type": "Usage",
    "timeframe": "MonthToDate",
    "dataset": {
      "granularity": "Daily",
      "aggregation": {
        "totalCost": {
          "name": "PreTaxCost",
          "function": "Sum"
        }
      },
      "grouping": [
        {
          "type": "Dimension",
          "name": "ResourceGroup"
        }
      ],
      "filter": {
        "dimensions": {
          "name": "Tags",
          "operator": "In",
          "values": [department_tag]
        }
      }
    }
  }
  
  return client.query.usage(subscription_id, query)

Automated Cost Controls

# Create automation runbook for cost enforcement
az automation runbook create \
  --name "StopHighCostResources" \
  --resource-group myResourceGroup \
  --automation-account-name myAutomationAccount \
  --type PowerShell \
  --location eastus

Reserved Instance Optimization

# Analyze RI recommendations
az reservations list-catalog \
  --query "[?contains(name, 'VM')] | [0:5]"

# Purchase optimal RIs
az reservations purchase \
  --sku Standard_B2s \
  --term P3Y \
  --scope Single

Key Takeaways

  • **Cost attribution** enables departmental billing
  • **Automation** enforces cost policies
  • **RI optimization** maximizes savings
  • **Monitoring** identifies optimization opportunities

Next Steps

Implement enterprise governance frameworks.


Resources

Python Docs

Ojasa Mirai

Master AI-powered development skills through structured learning, real projects, and verified credentials. Whether you're upskilling your team or launching your career, we deliver the skills companies actually need.

Learn Deep • Build Real • Verify Skills • Launch Forward

Courses

PythonFastapiReactJSCloud

© 2026 Ojasa Mirai. All rights reserved.

TwitterGitHubLinkedIn