【发布时间】:2020-07-28 02:39:05
【问题描述】:
以下是我用于创建 SQL 虚拟机的完整代码,在创建资源时出现以下错误,我尝试通过以下方式进行调试
-
将 azurerm 固定到特定版本,
-
提高了该位置的订阅配额限制。 它以前运行良好,但突然抛出错误。
#Database Server 1 provider "azurerm" { version = "2.10" features {} } resource "azurerm_resource_group" "RG" { name = "resource_db" location = var.location } resource "azurerm_virtual_network" "VN" { name = "vnet_db" resource_group_name = azurerm_resource_group.RG.name location = azurerm_resource_group.RG.location address_space = ["10.10.0.0/16"] } resource "azurerm_subnet" "DBSN" { name = "snet_db" resource_group_name = azurerm_resource_group.RG.name virtual_network_name = azurerm_virtual_network.VN.name address_prefixes = ["10.10.2.0/24"] } resource "azurerm_public_ip" "DBAZPIP" { name = "pip_db" resource_group_name = azurerm_resource_group.RG.name location = azurerm_resource_group.RG.location allocation_method = "Static" } resource "azurerm_network_security_group" "NSGDB" { name = "nsg_db" location = azurerm_resource_group.RG.location resource_group_name = azurerm_resource_group.RG.name # RDP security_rule { name = "RDP" priority = 300 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "3389" source_address_prefix = "*" destination_address_prefix = "*" } security_rule { name = "SQL" priority = 310 direction = "Inbound" access = "Allow" protocol = "Tcp" source_port_range = "*" destination_port_range = "1433" source_address_prefix = "*" destination_address_prefix = "*" } } resource "azurerm_subnet_network_security_group_association" "mainDB" { subnet_id = azurerm_subnet.DBSN.id network_security_group_id = azurerm_network_security_group.NSGDB.id } resource "azurerm_network_interface" "vmnicprimary" { name = "nic_db" location = azurerm_resource_group.RG.location resource_group_name = azurerm_resource_group.RG.name ip_configuration { name = "ipConfig_db" subnet_id = azurerm_subnet.DBSN.id private_ip_address_allocation = "Dynamic" public_ip_address_id = azurerm_public_ip.DBAZPIP.id } } resource "azurerm_virtual_machine" "DatabaseServer" { name = "vm_db" location = azurerm_resource_group.RG.location resource_group_name = azurerm_resource_group.RG.name network_interface_ids = [azurerm_network_interface.vmnicprimary.id,] vm_size = "Standard_D4s_v3" storage_image_reference { publisher = "MicrosoftSQLServer" offer = "SQL2017-WS2016" sku = "Enterprise" version = "latest" } storage_os_disk { name = "osdisk_db" caching = "ReadWrite" create_option = "FromImage" managed_disk_type = "Premium_LRS" } os_profile { computer_name = "compdb" admin_username = "vmadmin" admin_password = "P@ssW0rd123456" } os_profile_windows_config { provision_vm_agent = true enable_automatic_upgrades = true } } resource "azurerm_mssql_virtual_machine" "example" { virtual_machine_id = azurerm_virtual_machine.DatabaseServer.id sql_license_type = "PAYG" sql_connectivity_type = "PUBLIC" }
运行上面的代码会抛出以下错误:
Error: retrieving Sql Virtual Machine (Sql Virtual Machine Name "vm_m2m80" / Resource Group "resource_m2m80"): sqlvirtualmachine.SQLVirtualMachinesClient#Get: Failure responding to request: StatusCode=500 -- Original Error: autorest/azure: Service returned an error. Status=500 Code="InternalServerError" Message="An unexpected error occured while processing the request. Tracking ID: '9a1622b0-f7d1-4070-96c0-ca67d66a3522'"
on main.tf line 117, in resource "azurerm_mssql_virtual_machine" "example":
117: resource "azurerm_mssql_virtual_machine" "example" {
【问题讨论】:
-
请您编辑您的问题以分享您的 Terraform 代码,最好是 minimal reproducible example,以便其他人可以重现您的问题?
-
@ydaetskcoR 我已按照建议添加了代码
-
您还应该包含错误的周围上下文(例如,哪个 Terraform 资源引发了错误)并将其粘贴在代码块中以便更好地格式化。
-
@ydaetskcoR 希望这会有所帮助
标签: azure terraform terraform-provider-azure