Skip to content

Configuring usage patterns

Kamil Mrzygłód edited this page Feb 10, 2024 · 13 revisions

Available from: 1.0


To achieve better accurracy with estimations, you can leverage usage patterns feature. If usage pattern is specified for a resource type, ACE will use provided value for calculating monthly cost. Usage patterns are defined as a block inside metadata object for both ARM Templates and Azure Bicep. You must name that block aceUsagePatterns so ACE can parse them correctly:

ARM Template

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.12.40.16777",
      "templateHash": "8060235446393778821"
    },
    "aceUsagePatterns": {
      "Microsoft_ContainerRegistry_registries_Registry_Unit": "15",
      "Microsoft_ContainerRegistry_registries_Data_Stored": "50",
      "Microsoft_ContainerRegistry_registries_Task_vCPU_Duration": "3600"
    }
  },
  "resources": [
    {
      "type": "Microsoft.ContainerRegistry/registries",
      "apiVersion": "2021-09-01",
      "name": "metadataacr",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "Basic"
      }
    }
  ]
}

Bicep

metadata aceUsagePatterns = {
  Microsoft_ContainerRegistry_registries_Registry_Unit: '15'
  Microsoft_ContainerRegistry_registries_Data_Stored: '50'
  Microsoft_ContainerRegistry_registries_Task_vCPU_Duration: '3600'
}

resource acr 'Microsoft.ContainerRegistry/registries@2021-09-01' = {
  name: 'metadataacr'
  location: resourceGroup().location
  sku: {
    name: 'Basic'
  }
}

Metadata object in Azure Bicep was introduced quite recently - make sure you've updated Bicep CLI / Azure CLI to get support for it.

Note, that value of each usage pattern is passed as string. This is done to simplify logic behind parsing the parameters - finally, ACE takes care of proper casting.

Supported usage patterns

Below table shows currently implemented support for usage patterns. Resources not listed are considered TBD:

Service Metric Data type Availability
ACR Microsoft_ContainerRegistry_registries_Registry_Unit Days 1.0
ACR Microsoft_ContainerRegistry_registries_Data_Stored GB 1.0
ACR Microsoft_ContainerRegistry_registries_Task_vCPU_Duration Second 1.0
Automation Account Microsoft_Automation_automationAccounts_Basic_Runtime Minutes > 1.4-beta1
Automation Account Microsoft_Automation_automationAccounts_Watcher_Count number > 1.4-beta1
Backup Microsoft_RecoveryServices_vaults_Data_Stored GB > 1.1-beta1
Key Vault Microsoft_KeyVault_vaults_Certificate_Renewal_Requests number > 1.5-beta1
Key Vault Microsoft_KeyVault_vaults_Automated_Key_Rotation number > 1.5-beta1
Key Vault Microsoft_KeyVault_vaults_Secret_Renewal number > 1.5-beta1
Key Vault Microsoft_KeyVault_vaults_Advanced_Key_Operations number > 1.5-beta1
Key Vault Microsoft_KeyVault_vaults_Operations number > 1.5-beta1
Log Analytics Microsoft_OperationalInsights_workspaces_Paug_Data_Ingestion GB > 1.0
Maria DB Microsoft_DBforMariaDB_servers_Backup_Storage GB > 1.1-beta2
PostgreSQL Microsoft_DBforPostgreSQL_servers_Backup_Storage GB > 1.1-beta2
SQL Database Microsoft_Sql_servers_Hybrid_Benefit_Enabled any > 1.1-beta1
SQL Database Microsoft_Sql_servers_databases_DTU_Storage GB > 1.1-beta1
SQL Database Microsoft_Sql_servers_databases_vCore_Storage GB > 1.2-beta3
Virtual Network Microsoft_Network_virtualNetworks_Inbound_data_transfer GB > 1.1-beta1
Virtual Network Microsoft_Network_virtualNetworks_Outbound_data_transfer GB > 1.1-beta1

Note, that usage patterns are applied for all resources of given type. For example, if you use Microsoft_ContainerRegistry_registries_Task_vCPU_Duration metric, its value will be applied to all Azure Container Registries defined within your template. This behavior will probably change in the future releases.

If you search for additional details, check this page for advanced use.

Clone this wiki locally