Terraform无法在德国中西部地区创建azure VM

ybzsozfc  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(121)

我尝试在Germany West Central区域中创建azure虚拟机,但收到以下错误:
错误:计算。虚拟机客户端#创建或更新:发送请求失败:状态代码=0 --原始错误:Autorest/ Azure :服务返回错误。状态=代码=“SkuNotAvailable”消息=“位置”germanywestcentral“区域"订阅”中当前没有资源“/subscriptions//resourceGroups/shared-rg/providers/Microsoft.Compute/virtualMachines/jumphost”的请求大小。请尝试其他大小或部署到其他位置或区域。有关详细信息,请参阅https://aka.ms/azureskunotavailable。”│ │使用模块.jump_host_vm.azurerm_virtual_machine.vm,│位于模块/虚拟机/main.tf第1行,资源“azurerm虚拟机”“vm”中:│ 1:资源“azurerm虚拟机”“虚拟机”{
我正在使用Standard_A1_v2的大小和22.04-LTS的SKU。请在下面查找我的terraform代码:

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)
}

上述值如下:

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"
}

有人能帮我理解为什么它不工作吗?根据azure站点[1],这个VM在德国地区可用。
[1]- https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?regions=all&products=virtual-machines

ubof19bj

ubof19bj1#

看起来规范:Ubuntu Server:22.04-LTS:latest”不可用,并且正在预览中。我们可以使用以下版本16.04-LTS /19_10-daily-gen 2**对于16.04版本,虚拟机大小为“Standard_A1_v2”*对于最新的SKU 19_10-daily-gen 2,支持的虚拟机大小为Standard_DS2_v2

storage_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS" //"19_10-daily-gen2"
    version   = "latest"
  }

此命令用于获取受支持的SKU版本

Get-AzVMImageSku -Location "Germany West Central" -PublisherName "Canonical" -Offer "UbuntuServer" | Select Skus

请从snippet主tf中找到以下示例代码参考,如下所示

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"
  }
}

提供程序文件,如下所示:

terraform {
  
      required_version = "~>1.3.3"
      required_providers {
        azurerm = {
           source = "hashicorp/azurerm"
           version = ">=3.0.0"
             }
           }
 }

 provider "azurerm" {
    features {}
    skip_provider_registration = true
}

在运行时

terraform plan

在应用时

terraform apply -auto-approve

UI验证

相关问题