Azure Monitor Autoscale Setting

This page shows how to write Terraform and Azure Resource Manager for Monitor Autoscale Setting and write them securely.

azurerm_monitor_autoscale_setting (Terraform)

The Autoscale Setting in Monitor can be configured in Terraform with the resource name azurerm_monitor_autoscale_setting. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

autoscale.tf#L1
resource "azurerm_monitor_autoscale_setting" "user15-autoscale-vmss1" {
  name                = "user15-autoscale-vmss1"
  resource_group_name = azurerm_resource_group.user15-rg-project.name
  location            = azurerm_resource_group.user15-rg-project.location
  target_resource_id  = azurerm_virtual_machine_scale_set.user15vmss1.id

autoscale.tf#L1
resource "azurerm_monitor_autoscale_setting" "user16vm-autoscale1" {
  name                        = "user16AutoscaleSetting1"
  resource_group_name = azurerm_resource_group.user16-rg.name
  location                    = azurerm_resource_group.user16-rg.location
  target_resource_id      = azurerm_virtual_machine_scale_set.user16vmss1.id

autoscale.tf#L1
resource "azurerm_monitor_autoscale_setting" "user04-autoscale-vmss1" {
  name                = "user04-autoscale-vmss1"
  resource_group_name = azurerm_resource_group.user04-rg-project.name
  location            = azurerm_resource_group.user04-rg-project.location
  target_resource_id  = azurerm_virtual_machine_scale_set.user04vmss1.id

autoscaling.tf#L1
resource "azurerm_monitor_autoscale_setting" "example" {
  name                = "demo-autoscaling"
  resource_group_name = azurerm_resource_group.demo.name
  location            = var.location
  target_resource_id  = azurerm_virtual_machine_scale_set.demo.id

main.tf#L1
resource "azurerm_monitor_autoscale_setting" "autoscale" {
  name                = "autoscale-cpu"
  target_resource_id  = var.target_resource_id
  location            = var.location
  resource_group_name = var.resource_group_name
  enabled = var.enabled
autoscaling.tf#L1
resource "azurerm_monitor_autoscale_setting" "example" {
  name                = "demo-autoscaling"
  resource_group_name = azurerm_resource_group.demo.name
  location            = var.location
  target_resource_id  = azurerm_virtual_machine_scale_set.demo.id

main.tf#L1
resource "azurerm_monitor_autoscale_setting" "main" {
  name                = "autoscale-config"
  resource_group_name = var.resourcegrpname
  location            = var.resourceglocation
  target_resource_id  = var.vmss_id

autoscaling.tf#L1
resource "azurerm_monitor_autoscale_setting" "example" {
  name                = "demo-autoscaling"
  resource_group_name = azurerm_resource_group.demo.name
  location            = var.location
  target_resource_id  = azurerm_virtual_machine_scale_set.demo.id

autoscaling.tf#L1
resource "azurerm_monitor_autoscale_setting" "example" {
  name                = "demo-autoscaling"
  resource_group_name = azurerm_resource_group.demo.name
  location            = var.location
  target_resource_id  = azurerm_virtual_machine_scale_set.demo.id

autoscaling.tf#L1
resource "azurerm_monitor_autoscale_setting" "example" {
  name                = "demo-autoscaling"
  resource_group_name = azurerm_resource_group.demo.name
  location            = var.location
  target_resource_id  = azurerm_virtual_machine_scale_set.demo.id

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a AutoScale Setting which can be applied to Virtual Machine Scale Sets, App Services and other scalable resources.

Tips: Best Practices for The Other Azure Monitor Resources

In addition to the azurerm_monitor_log_profile, Azure Monitor has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_monitor_log_profile

Ensure to enable the activity retention log

It is better to enable the activity retention log to ensure that all the information required for an effective investigation is still available.

Review your Azure Monitor settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Insights/autoscaleSettings (Azure Resource Manager)

The autoscaleSettings in Microsoft.Insights can be configured in Azure Resource Manager with the resource name Microsoft.Insights/autoscaleSettings. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

DeploymentUnitsTest.test_app_service_plan_autoscale.json#L163
                        "type": "Microsoft.Insights/autoscaleSettings",
                        "location": "West US",
                        "tags": {
                            "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
                        },
                        "properties": {
as_default.json#L3
    "type": "Microsoft.Insights/autoscaleSettings",
    "name": "[variables('asName')]",
    "location": "[variables('location')]",
    "dependsOn": [
        "[variables('vmRef')]"
    ],
autoscale.json#L4
    "type": "Microsoft.Insights/autoscaleSettings",
    "location": "southeastasia",
    "tags": {
        "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
    },
    "properties": {
as_default.json#L3
    "type": "Microsoft.Insights/autoscaleSettings",
    "name": "[variables('asName')]",
    "location": "[variables('location')]",
    "dependsOn": [
        "[variables('vmRef')]"
    ],
DeploymentUnitsTest.test_app_service_plan_autoscale.json#L163
                        "type": "Microsoft.Insights/autoscaleSettings",
                        "location": "West US",
                        "tags": {
                            "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
                        },
                        "properties": {
ResourceLogAutoScaleARMTemplate.json
{
    "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "autoscaleSettingName": {
DeploymentUnitsTest.test_app_service_plan_autoscale.json#L163
                        "type": "Microsoft.Insights/autoscaleSettings",
                        "location": "West US",
                        "tags": {
                            "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
                        },
                        "properties": {
azuredeploy-nested-services-custom.json#L90
      "type": "Microsoft.Insights/autoscaleSettings",
      "name": "[parameters('cdHostingplanAutoscaleName')]",
      "apiVersion": "2014-04-01",
      "location": "[parameters('cdProductionWebApp').location]",
      "tags": {},
      "scale": null,

Frequently asked questions

What is Azure Monitor Autoscale Setting?

Azure Monitor Autoscale Setting is a resource for Monitor of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Monitor Autoscale Setting?

For Terraform, the azure-user15/vmss, fantasthan/user16 and rulrugit/user04 source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the LRuttenCN/cloud-custodian, cloudyr/AzureVM and freebo/azure-metadata source code examples are useful. See the Azure Resource Manager Example section for further details.