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
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
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
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
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
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
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
resource "azurerm_monitor_autoscale_setting" "main" {
name = "autoscale-config"
resource_group_name = var.resourcegrpname
location = var.resourceglocation
target_resource_id = var.vmss_id
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
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
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
Parameters
-
enabled
optional - bool -
id
optional computed - string -
location
required - string -
name
required - string -
resource_group_name
required - string -
tags
optional - map from string to string -
target_resource_id
required - string -
notification
list block-
email
list block-
custom_emails
optional - list of string -
send_to_subscription_administrator
optional - bool -
send_to_subscription_co_administrator
optional - bool
-
-
webhook
list block-
properties
optional - map from string to string -
service_uri
required - string
-
-
-
profile
list block-
name
required - string -
capacity
list block -
fixed_date
list block -
recurrence
list block -
rule
list block-
metric_trigger
list block-
metric_name
required - string -
metric_namespace
optional - string -
metric_resource_id
required - string -
operator
required - string -
statistic
required - string -
threshold
required - number -
time_aggregation
required - string -
time_grain
required - string -
time_window
required - string -
dimensions
list block
-
-
scale_action
list block
-
-
-
timeouts
single block
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.
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.
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
"type": "Microsoft.Insights/autoscaleSettings",
"location": "West US",
"tags": {
"$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
},
"properties": {
"type": "Microsoft.Insights/autoscaleSettings",
"name": "[variables('asName')]",
"location": "[variables('location')]",
"dependsOn": [
"[variables('vmRef')]"
],
"type": "Microsoft.Insights/autoscaleSettings",
"location": "southeastasia",
"tags": {
"$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
},
"properties": {
"type": "Microsoft.Insights/autoscaleSettings",
"name": "[variables('asName')]",
"location": "[variables('location')]",
"dependsOn": [
"[variables('vmRef')]"
],
"type": "Microsoft.Insights/autoscaleSettings",
"location": "West US",
"tags": {
"$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
},
"properties": {
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"autoscaleSettingName": {
"type": "Microsoft.Insights/autoscaleSettings",
"location": "West US",
"tags": {
"$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary, Microsoft.WindowsAzure.Management.Common.Storage"
},
"properties": {
"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.