» azurerm_mssql_virtual_machine

Manages a Microsoft SQL Virtual Machine

» Example Usage

This example provisions a brief Managed MsSql Virtual Machine. The detailed example of the azurerm_mssql_virtual_machine resource can be found in the ./examples/mssql/mssqlvm directory within the Github Repository

data "azurerm_virtual_machine" "example" {
  name                = "example-vm"
  resource_group_name = "example-resources"
}

resource "azurerm_mssql_virtual_machine" "example" {
  virtual_machine_id               = data.azurerm_virtual_machine.example.id
  sql_license_type                 = "PAYG"
  r_services_enabled               = true
  sql_connectivity_port            = 1433
  sql_connectivity_type            = "PRIVATE"
  sql_connectivity_update_password = "Password1234!"
  sql_connectivity_update_username = "sqllogin"

  auto_patching {
    day_of_week                            = "Sunday"
    maintenance_window_duration_in_minutes = 60
    maintenance_window_starting_hour       = 2
  }

}

» Argument Reference

The following arguments are supported:


The auto_patching block supports the following:


The key_vault_credential block supports the following:

  • name - (Required) The credential name.

  • key_vault_url - (Required) The azure Key Vault url. Changing this forces a new resource to be created.

  • service_principal_name - (Required) The service principal name to access key vault. Changing this forces a new resource to be created.

  • service_principal_secret - (Required) The service principal name secret to access key vault. Changing this forces a new resource to be created.


The storage_configuration block supports the following:

  • disk_type - (Required) The type of disk configuration to apply to the SQL Server. Valid values include NEW, EXTEND, or ADD.

  • storage_workload_type - (Required) The type of storage workload. Valid values include GENERAL, OLTP, or DW.

  • data_settings - (Optional) An storage_settings as defined below.

  • log_settings - (Optional) An storage_settings as defined below.

  • temp_db_settings - (Optional) An storage_settings as defined below.


The storage_settings block supports the following:

  • default_file_path - (Required) The SQL Server default path

  • luns - (Required) A list of Logical Unit Numbers for the disks.

» Attributes Reference

The following attributes are exported: * id - The ID of the SQL Virtual Machine.

» Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 60 minutes) Used when creating the MSSQL Virtual Machine.
  • update - (Defaults to 60 minutes) Used when updating the MSSQL Virtual Machine.
  • read - (Defaults to 5 minutes) Used when retrieving the MSSQL Virtual Machine.
  • delete - (Defaults to 60 minutes) Used when deleting the MSSQL Virtual Machine.

» Import

Sql Virtual Machines can be imported using the resource id, e.g.

$ terraform import azurerm_mssql_virtual_machine.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/example1