Terraform无法在德国中西部区域创建Azure VM求助
问题详情
尝试在Germany West Central(德国中西部)区域创建Azure虚拟机时,触发如下错误:
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" {
使用的VM规格为Standard_A1_v2,操作系统SKU为22.04-LTS。
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官网显示,Standard_A1_v2规格在德国区域是可用的,为什么创建会失败?
问题解答
导致该错误的常见原因及对应解决办法如下:
- 订阅级配额/可用性限制:Azure官网显示的区域可用性是全局层面,但你的订阅可能在该区域没有
Standard_A1_v2的配额,或是该SKU在当前订阅下暂时资源耗尽。可通过Azure CLI查询当前订阅的SKU状态:
若结果显示az vm list-skus --location germanywestcentral --size Standard_A1_v2 --output tableNotAvailableForSubscription,可提交配额提升申请。 - 资源组所在分区库存不足:即使区域整体支持该SKU,你创建VM的资源组对应的具体可用区(或无可用区)可能暂时无库存。可尝试指定可用区(如在VM资源中添加
zones = ["1"]),或更换同系列其他规格(如Standard_A2_v2)。 - 临时区域资源短缺:Azure区域资源供应可能存在临时波动,间隔一段时间重试创建操作可能成功。
- 参数核对:检查代码注释与实际变量值的一致性(代码注释写的是
20.04-LTS,但变量是22.04-LTS),确认Terraform执行时实际使用的参数正确。
内容的提问来源于stack exchange,提问作者Jananath Banuka

