Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (13.1k points)
Can anyone help me How I can able to request for Azure Spot instances for Linux Virtual Machine Scale Set? Also, I tried to put priority and eviction_policy but it throws an error.

1 Answer

0 votes
by (26.7k points)

You can try with the below code, and this will help for the spot instances:

resource "azurerm_linux_virtual_machine_scale_set" "example" {

  name                = "example-vmss"

  resource_group_name = azurerm_resource_group.example.name

  location            = azurerm_resource_group.example.location

  sku                 = "Standard_F2"

  instances           = 1

  admin_username      = "adminuser"

  priority = "Spot"

  eviction_policy = "Deallocate"

  admin_ssh_key {

    username   = "adminuser"

    public_key = file("~/.ssh/id_rsa.pub")

  }

  source_image_reference {

    publisher = "Canonical"

    offer     = "UbuntuServer"

    sku       = "16.04-LTS"

    version   = "latest"

  }

  os_disk {

    storage_account_type = "Standard_LRS"

    caching              = "ReadWrite"

  }

  network_interface {

    name    = "example"

    primary = true

    ip_configuration {

      name      = "internal"

      primary   = true

      subnet_id = azurerm_subnet.internal.id

    }

  }

}

I hope this will help.

Want to become an Azure expert? join Azure Training now!!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...