Home > Software engineering >  Receiving a 'Invalid Parameter' SKU error when trying to create a Linux VM Scale Set in Az
Receiving a 'Invalid Parameter' SKU error when trying to create a Linux VM Scale Set in Az

Time:08-09

I am a beginner learning Terraform and need some advice. I am trying to create a Linux VM Scale Set in Azure using Terraform. I used the code in the Terraform documentation to set the source_image_reference like this:

# Configure the Azure VM scale set
resource "azurerm_linux_virtual_machine_scale_set" "demo-vmss" {
  name = "demo-vmss"
  location = azurerm_resource_group.demo-rg.location
  resource_group_name = azurerm_resource_group.demo-rg.name
  admin_username = "admin-user"
  admin_password = "Password123!"
  instances = 2
  zones = [1,2,3]
  sku = "Standard_B1s"

source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "20.04 LTS"
    version   = "latest"
    }

  os_disk {
    caching = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  network_interface {
    name = "demo-network-interface"

    ip_configuration {
      name = "vmss-ip-config"
      primary = true
      subnet_id = azurerm_subnet.vm-subnet.id
    }
  }
}

No matter what value I put for the sku or offer in the source_image_reference, I receive this error in PowerShell:

creating Linux Virtual Machine Scale Set: (Name "demo-vmss" / Resource Group "myTFResourceGroup"): 
compute.VirtualMachineScaleSetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter imageReference.offer 
is invalid." Target="imageReference.offer"

Can anyone please suggest what I can do to fix this error and what is causing the problem (so I can learn for future)? This is my first time writing a question here so please let me know if you need me to provide more information. Any help provided will be much appreciated.

CodePudding user response:

The offer and SKUs for Ubuntu changed recently. See the following links for details: https://lnx.azurewebsites.net/ubuntu-new-offers-and-skus-for-azure-vms/amp/

Creating an Azure Linux VM with Ubuntu 20.04 with Terraform

https://discourse.ubuntu.com/t/find-ubuntu-images-on-microsoft-azure/18918

CodePudding user response:

This error may occur in imageReference.offerWhen I try to discover that it is available but goes by a different name and is in fact sort of hidden, use below as same

source_image_reference {
    publisher = "Canonical"
    offer     = "0001-com-ubuntu-server-focal"
    sku       = "20_04-lts-gen2"```
    version   = "latest"
    }
  • Related