我在";通过构建开发环境使用Azure学习Terraform–初学者完整课程";不确定我是否可以发布链接,但是(https://www.youtube.com/watch?v=V53AHWun17s)大约在第53分钟,我遇到了问题。当实现代码的这一部分时,我得到了这个错误:
resource "azurerm_linux_virtual_machine" "mtc-vm" {
name = "mtc-vm"
resource_group_name = azurerm_resource_group.mtc-rg.name
location = azurerm_resource_group.mtc rg.location
size = "Standard_B1s"
admin_username = "adminuser"
network_interface_ids = [azurerm_network_interface.mtc-nic.id]
admin_ssh_key {
username = "adminuser"
public_key = file("~/.ssh/mtcazurekey.pub")
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "18.04-LTS"
version = "latest"
}
tags = {
"environment" = "dev"
}
}
错误:创建Linux虚拟机:(名称"mtc-vm"/资源组"mtc-resources"(:compute。VirtualMachinesclient#CreateOru update:发送请求失败:StatusCode=404--原始错误:Code=";平台图像未找到";消息=";平台映像"Canoni cal:UbuntuServer:16.04 LTS:latest"不可用。验证存储配置文件中的所有字段是否正确。有关存储配置文件信息的更多详细信息,请参阅https://aka.ms/storageprofile"target=";imageReference";
使用azurerm-linux-virtualmachine.mtc-vm,在main.tf的第97行,在资源"中;azurerm_ linux_虚拟机"mtc vm":97:资源";azurerm_linux_virtual_machine"quot;mtc vm";{
基于注释。这个问题是由在实际的TF代码中使用旧的Ubuntu18.04-LTS
引起的。更改为CCD_3并修改其他设置(未说明是哪些设置(,解决了此问题。