gpt4 book ai didi

azure - 使用terraform创建SQL虚拟机抛出错误

转载 作者:行者123 更新时间:2023-12-03 02:36:45 25 4
gpt4 key购买 nike

下面是我用来创建 SQL 虚拟机的完整代码,在创建资源时出现下面提到的错误,我尝试通过进行调试

  1. 将 azurerm 固定到特定版本,

  2. 增加了该位置的订阅配额限制。之前运行良好,突然抛出错误。

          #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" {

最佳答案

TLDR:已修复!!

来自微软的更新:

The fix has been released

“希望您一切顺利。我们已内部确认,很快就会修复此问题。一旦部署,我会向您更新。”

我们也遇到了同样的事情,使用各种 Terraform 和 Azure API 版本,每次构建都失败,这种情况是两天前开始发生的。当尝试导入以声明它时也会超时..

Error: reading Sql Virtual Machine (Sql Virtual Machine Name "sqlvmname" / Resource Group "resource group"): sqlvirtualmachine.SQLVirtualMachinesClient#Get: Failure sending request: StatusCode=500 -- Original Error: context deadline exceeded

我认为这是一个 API 问题。我们联系了 Microsoft 支持,他们能够使用此页面重现该问题(谢谢:))。他们正在内部检查,并正在微软调动更多资源来检查。与此同时,我认为没有什么可以做的。

一种可能的解决方法 - 实际上确实在 Azure 中创建了资源,可能是使用 Terraform 创建它,然后注释掉你的代码 - 由于它不处于状态,因此不会删除它。不太漂亮..

关于azure - 使用terraform创建SQL虚拟机抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62896398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com