Skip to content

Configuring usage patterns

Kamil Mrzygłód edited this page Jan 4, 2023 · 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 metadata object for both ARM Templates and Azure Bicep:

{
  "$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"
      }
    }
  ]
}
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.

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
Log Analytics Microsoft_OperationalInsights_workspaces_Paug_Data_Ingestion GB > 1.0

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 below sections for advanced use.

Log Analytics

While Log Analytics supports Microsoft_OperationalInsights_workspaces_Paug_Data_Ingestion usage pattern in ACE, you can achieve more granular usage calculation if you leverage dailyQuotaGb parameter:

resource la 'Microsoft.OperationalInsights/workspaces@2022-10-01' = {
  name: 'infer-la-cost'
  location: rgLocation
  properties: {
    sku: {
      name: 'PerGB2018'
    }
    workspaceCapping: {
      dailyQuotaGb: 5
    }
  }
}

If dailyQuotaGb is defined, it overrides any value defined by Microsoft_OperationalInsights_workspaces_Paug_Data_Ingestion pattern.

Azure Container Registry

As Microsoft_ContainerRegistry_registries_Task_vCPU_Duration first 100 minutes are free, when usage pattern for this metric is used, it'll incorporate the free tier. Thus anytime you define custom value for Microsoft_ContainerRegistry_registries_Task_vCPU_Duration, ACE will report no cost for it until you define more than 100 minutes of its use.

Clone this wiki locally