I tried to create the Azure VM with boot diagnostics and still not successful and got this error. terraform validation and plan pass and only encounter this error when I run terraform apply. I can create VM successfully after remove the boot diagnostics part but that’s not what I want.
Any idea how to fix it?
compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter bootDiagnostics.storageAccountUri is invalid." Target="bootDiagnostics.storageAccountUri"
Below are my configuration.
resource "azurerm_windows_virtual_machine" "vm-01" {
name = "${var.vmlist["0"]}"
resource_group_name = var.azurerm_resource_group
location = var.location
size = var.vmsize["B2s"]
admin_username = var.wincred[0]
admin_password = var.wincred[1]
network_interface_ids = [
azurerm_network_interface.nic01.id,
]
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = var.vmimgsku["2022-dc-aec"]
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
patch_mode = "AutomaticByPlatform"
hotpatching_enabled = true
tags = {
environment = "iis"
}
boot_diagnostics {
storage_account_uri = "storageaccountname"
}
}