下面是我用于创建SQL虚拟机的完整代码,在创建资源时遇到以下提到的错误,我尝试通过以下方式进行调试
将天青石固定到特定版本,
增加了该位置的订阅配额限制。 以前运行良好,突然抛出了错误。
#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" {
答案 0 :(得分:1)
TLDR:已修复!
Microsoft更新:
此修复程序已发布
”希望您会感觉很好。 我们已在内部确认,很快将解决此问题。部署后,我将对其进行更新。”
我们有同样的事情,每一次构建都会失败,使用各种Terraform和Azure API版本,这是两天前开始发生的事情。尝试导入时也要声明超时。.
错误:正在读取Sql虚拟机(Sql虚拟机名称为“ sqlvmname” /资源组为“资源组”):sqlvirtualmachine.SQLVirtualMachinesClient#Get:发送请求失败:StatusCode = 500-原始错误:超出上下文期限
我认为这是API问题。我们已与Microsoft支持部门联系,他们能够使用此页面重现该问题(谢谢:))。他们正在内部进行检查,并且正在Microsoft投入更多资源进行检查。同时,我认为没有什么可以做的。
一种可能的解决方法-看到这确实是在Azure中创建资源的,可能是使用Terraform创建资源,然后注释掉了您的代码-并且由于它不在状态,所以不会删除它。不漂亮。