I am trying to create an azure
vm in the Germany West Central
region but I am getting the following error:
Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status= Code="SkuNotAvailable" Message="The requested size for resource '/subscriptions//resourceGroups/shared-rg/providers/Microsoft.Compute/virtualMachines/jumphost' is currently not available in location 'germanywestcentral' zones '' for subscription ''. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details." │ │ with module.jump_host_vm.azurerm_virtual_machine.vm, │ on modules/virtual-machine/main.tf line 1, in resource "azurerm_virtual_machine" "vm": │ 1: resource "azurerm_virtual_machine" "vm" {
I am using the Standard_A1_v2
size and SKU of 22.04-LTS
. Please fin my terraform
code below:
resource "azurerm_virtual_machine" "vm" {
name = var.vm_name
location = var.location
resource_group_name = var.rg_name
network_interface_ids = var.nic_id
vm_size = var.vm_size #"Standard_A1_v2"
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true
storage_image_reference {
publisher = var.storage_image_reference.publisher #"Canonical"
offer = var.storage_image_reference.offer #"UbuntuServer"
sku = var.storage_image_reference.sku #"20.04-LTS"
version = var.storage_image_reference.version #"latest"
}
storage_os_disk {
name = var.storage_os_disk.name #"myosdisk1"
caching = var.storage_os_disk.caching #"ReadWrite"
create_option = var.storage_os_disk.create_option #"FromImage"
managed_disk_type = var.storage_os_disk.managed_disk_type #"Standard_LRS"
}
os_profile_linux_config {
disable_password_authentication = true
}
tags = merge(var.common_tags)
}
and the values for the above is as follows:
jump_host_vm_name = "jumphost"
jump_host_vm_size = "Standard_A1_v2"
jump_host_storage_image_reference = {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "22.04-LTS"
version = "latest"
}
jump_host_storage_os_disk = {
name = "myosdisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
Can someone help me understand why it is not working? According to the azure site [1], this VM is available in the Germany region.
CodePudding user response:
Seems the Canonical:UbuntuServer:22.04-LTS:latest" was not available and its under preview. we can use bellowed version 16.04-LTS /19_10-daily-gen2 For 16.04 version, VM size as "Standard_A1_v2" For latest sku 19_10-daily-gen2, supported VM size will be Standard_DS2_v2
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS" //"19_10-daily-gen2"
version = "latest"
}
Here is the command to get the supported versions of SKUs
Get-AzVMImageSku -Location "Germany West Central" -PublisherName "Canonical" -Offer "UbuntuServer" | Select Skus
please find below sample code reference from snippet main tf as follows
data "azurerm_resource_group" "example" {
name = "***********"
}
data "azuread_client_config" "current" {}
resource "azurerm_virtual_network" "puvnet" {
name = "Public_VNET"
resource_group_name = data.azurerm_resource_group.example.name
location = "Germany West Central"
address_space = ["10.19.0.0/16"]
dns_servers = ["10.19.0.4", "10.19.0.5"]
}
resource "azurerm_subnet" "osubnet" {
name = "Outer_Subnet"
resource_group_name = data.azurerm_resource_group.example.name
address_prefixes = ["10.19.1.0/24"]
virtual_network_name = azurerm_virtual_network.puvnet.name
}
resource "azurerm_network_interface" "main" {
name = "testdemo"
location = "Germany West Central"
resource_group_name = data.azurerm_resource_group.example.name
ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.osubnet.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_virtual_machine" "main" {
name = "vmjumphost"
location = "Germany West Central"
resource_group_name = data.azurerm_resource_group.example.name
network_interface_ids = [azurerm_network_interface.main.id]
vm_size = "Standard_A1_v2"
storage_image_reference {
offer = "UbuntuServer"
publisher = "Canonical"
sku = "19_10-daily-gen2"
version = "latest"
}
storage_os_disk {
name = "myosdisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hostname"
admin_username = "********"
admin_password = "*********"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags = {
environment = "staging"
}
}
provider file as follow:
terraform {
required_version = "~>1.3.3"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.0.0"
}
}
}
provider "azurerm" {
features {}
skip_provider_registration = true
}
Upon running on
terraform plan
upon apply
terraform apply -auto-approve
Verification from UI