Azure Cost Management And Billing
Intro
My notes on how to keep track of Azure costs
Documentation
Use tags to organize your Azure resources and management hierarchy
Track costs across business units, environments, or projects
Tips and Tidbits
Use tags to organize resources into an appropriate taxonomy.
Each tag consists of a name and a value pair.
There is a maximum of 15 tags that can be associated with a resource (VM, Network, etc.) or resource group.
Tagging is an easy way to classify assets.
Tagging associates metadata to an asset.
That metadata can be used to classify the asset based on various data points.
When tags are used to classify assets as part of a cost management effort, companies often need the following tags: business unit, department, billing code, geography, environment, project, and workload or application categorization
Tags applied to the resource group or subscription aren't inherited by the resources.
To apply tags from a subscription or resource group to the resources, see Azure Policies - tags.
You need to perform a remediation task to create/update tags for the resources in the resource group/subscription.
Azure PowerShell offers two commands for applying tags: New-AzTag and Update-AzTag
Azure CLI offers two commands for applying tags: az tag create and az tag update.
The
az tag create
replaces all tags on the resource, resource group, or subscription
You can tag resources, resource groups, and subscriptions during deployment with an Azure Resource Manager template (ARM template).
The tags you apply through an ARM template or Bicep file overwrite any existing tags.
You cannot apply tags at the management group level but you can use Azure policies that manage tags at the management group level.
If an “Add a tag” policy conflicts with a resource that already has the same tag, the tag on the resource will not be changed.
Existing resource groups can be remediated by triggering a remediation task
See policy definitions and their effects on existing tags: Assign policy definitions for tag compliance
The spending limit in Azure prevents spending over your credit amount.
All new customers who sign up for an Azure free account or subscription types that include credits over multiple months have the spending limit turned on by default
When your usage results in charges that exhaust your spending limit, the services that you deployed are disabled for the rest of that billing period.
When you spend all the credit included with your Azure free account, Azure resources that you deployed are removed from production and your Azure virtual machines are stopped and de-allocated.
The data in your storage accounts are available as read-only.
If your subscription type includes credits over multiple months, your subscription is re-enabled automatically at the beginning of the next billing period.
Then you can redeploy your Azure resources and have full access to your storage accounts and databases.
Group and filter options in Cost analysis
Tags and billing
You can use tags to group your billing data. For example, if you're running multiple VMs for different organizations, use the tags to group usage by cost center.
You can also use tags to categorize costs by runtime environment, such as the billing usage for VMs running in the production environment.
You can retrieve information about tags by downloading the usage file, a comma-separated values (CSV) file available from the Azure portal.
For REST API operations, see Azure Billing REST API Reference.
Azure Budgets
Budgets can be scoped in Azure.
You could narrow your budget view based on subscription, resource groups, or a collection of resources.
In addition to using the budgets API to notify you via email when a budget threshold is reached, you can use Azure Monitor action groups to trigger an orchestrated set of actions resulting from a budget event.
Actions that can be taken with a budget threshold:
Create an Azure Automation Runbook to stop VMs by using webhooks.
Create an Azure Logic App to be triggered based on the budget threshold value and call the runbook with the right parameters.
Create an Azure Monitor Action Group that will be configured to trigger the Azure Logic App when the budget threshold is met.
Create the Azure budget with the wanted thresholds and wire it to the action group.
Billing Scope
Setting Budget Alerts
Create a budget alert at a resource group level
You can also add Actions to be performed
You can setup a runbook to shut down VMs