Azure Compute Virtual Machine Scale Set Extension

This page shows how to write Terraform and Azure Resource Manager for Compute Virtual Machine Scale Set Extension and write them securely.

azurerm_virtual_machine_scale_set_extension (Terraform)

The Virtual Machine Scale Set Extension in Compute can be configured in Terraform with the resource name azurerm_virtual_machine_scale_set_extension. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

vmss-extensions.tf#L2
resource "azurerm_virtual_machine_scale_set_extension" "oms_agent" {
  auto_upgrade_minor_version   = true
  name                         = "OMSExtension"
  publisher                    = "Microsoft.EnterpriseCloud.Monitoring"
  type                         = "OmsAgentForLinux"
  type_handler_version         = "1.4"
install.tf#L9
resource "azurerm_virtual_machine_scale_set_extension" "ue4extension" {
  name                 = var.extension_name
  depends_on           = []
  virtual_machine_scale_set_id    = var.virtual_machine_scale_set_id
  publisher            = "Microsoft.Compute"
  type                 = "CustomScriptExtension"
vmss-extensions.tf#L2
resource "azurerm_virtual_machine_scale_set_extension" "oms_agent" {
  auto_upgrade_minor_version   = true
  name                         = "OMSExtension"
  publisher                    = "Microsoft.EnterpriseCloud.Monitoring"
  type                         = "OmsAgentForLinux"
  type_handler_version         = "1.4"
vmss_extension.tf#L16
resource "azurerm_virtual_machine_scale_set_extension" "dynatrace_extension" {
  name                         = var.name
  virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.resource.id
  publisher                    = "dynatrace.ruxit"
  type                         = "oneAgentLinux"
  type_handler_version         = "1.0"
dataprovider1.tf#L15
resource "azurerm_virtual_machine_scale_set_extension" "example" {
  name                         = "examplevss"
  virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.example.id
  publisher                    = "Microsoft.Azure.Extensions"
  type                         = "CustomScript"
  type_handler_version         = "2.0"
main.tf#L1
resource "azurerm_virtual_machine_scale_set_extension" "dynatrace-oneagent" {

  count = var.virtual_machine_type == "vmss" ? 1 : 0

  name                         = "Dynatrace"
  virtual_machine_scale_set_id = var.virtual_machine_scale_set_id
main.tf#L7
resource "azurerm_virtual_machine_scale_set_extension" "this" {
  auto_upgrade_minor_version   = var.auto_upgrade_minor_version
  force_update_tag             = var.force_update_tag
  name                         = var.name
  protected_settings           = var.protected_settings
  provision_after_extensions   = var.provision_after_extensions
main.tf#L7
resource "azurerm_virtual_machine_scale_set_extension" "this" {
  auto_upgrade_minor_version   = var.auto_upgrade_minor_version
  force_update_tag             = var.force_update_tag
  name                         = var.name
  protected_settings           = var.protected_settings
  provision_after_extensions   = var.provision_after_extensions
vmss-ext-da.tf#L1
resource "azurerm_virtual_machine_scale_set_extension" "vmss_ext_da" {
  virtual_machine_scale_set_id = azurerm_windows_virtual_machine_scale_set.vmss.id
  auto_upgrade_minor_version   = true
  name                         = "DependencyAgentWindows"
  publisher                    = "Microsoft.Azure.Monitoring.DependencyAgent"
  type                         = "DependencyAgentWindows"
vmss-web-THEN-appgw-THEN-extension.tf#L3
resource "azurerm_virtual_machine_scale_set_extension" "new_terraform_vmss_web_ext_1" {
  name                         = "new_terraform_vmss_web_ext_1"
  virtual_machine_scale_set_id = azurerm_windows_virtual_machine_scale_set.new_terraform_vmss_web.id
    publisher = "Microsoft.Compute"
    type = "CustomScriptExtension"
    type_handler_version = "1.9"

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 an Extension for a Virtual Machine Scale Set.

NOTE: This resource is not intended to be used with the azurerm_virtual_machine_scale_set resource - instead it's intended for this to be used with the azurerm_linux_virtual_machine_scale_set and azurerm_windows_virtual_machine_scale_set resources.

Tips: Best Practices for The Other Azure Compute Resources

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

risk-label

azurerm_linux_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

risk-label

azurerm_managed_disk

Ensure to enable the encryption on managed disks

It is better to enable the encryption on managed disks.

risk-label

azurerm_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

Review your Azure Compute 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.Compute/virtualMachineScaleSets/extensions (Azure Resource Manager)

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

Example Usage from GitHub

An example could not be found in GitHub.

Frequently asked questions

What is Azure Compute Virtual Machine Scale Set Extension?

Azure Compute Virtual Machine Scale Set Extension is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Compute Virtual Machine Scale Set Extension?

For Terraform, the jamesrcounts/terraform-packer, jmarymee/Unreal-Pixel-Streaming-on-Azure and jamesrcounts/azure-devops-vmss-pool source code examples are useful. See the Terraform Example section for further details.