1

Below is the complete code that I am using to create the SQL virtual machine, while creating the resources I get the below mentioned error, I tried to debug by

  1. pinning the azurerm to a specific version,

  2. increased the quota limit of the subscription for the location. It was working well previously and has suddenly throwing the errors.

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

Running the above code throws the following error:

    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" {
4
  • Please can you edit your question to share your Terraform code, ideally as a minimal reproducible example, so that others can reproduce your issue? Commented Jul 14, 2020 at 13:45
  • 1
    @ydaetskcoR i have added the code as advised Commented Jul 14, 2020 at 14:05
  • You should also include the error's surrounding context (eg which Terraform resource threw the error) and stick that in a code block as well for better formatting. Commented Jul 14, 2020 at 14:07
  • 1
    @ydaetskcoR hopefully this helps Commented Jul 14, 2020 at 14:14

1 Answer 1

1

TLDR: It has been fixed!!

Update from Microsoft:

The fix has been released

"Hope this finds you well. We have confirmed internally, there will be a fix for this issue soon. I will update you once it is deployed."

We have the same thing, failing on every single build, using various Terraform and Azure API versions, this started happening two days ago for us. When trying to import to state it timeouts out as well..

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

I believe this is an API issue. We engaged Microsoft Support and they are able to reproduce the issue using this page(thank you :) ). They are checking internally and are engaging more resources at Microsoft to check it. In the meantime I don't think there is anything that can be done.

One possible work around - seeing as this actually does create the resource in Azure may be to create it using Terraform then comment out your code - and since it's not in state it wont delete it. Not pretty..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.