azurerm_mssql_virtual_machine_availability_group_listener

Manages a Microsoft SQL Virtual Machine Availability Group Listener.

Example Usage

data "azurerm_subnet" "example" {
  name                 = "examplesubnet"
  virtual_network_name = "examplevnet"
  resource_group_name  = "example-resources"
}

data "azurerm_lb" "example" {
  name                = "example-lb"
  resource_group_name = "example-resources"
}

data "azurerm_virtual_machine" "example" {
  count = 2

  name                = "example-vm"
  resource_group_name = "example-resources"
}

resource "azurerm_mssql_virtual_machine_group" "example" {
  name                = "examplegroup"
  resource_group_name = "example-resources"
  location            = "West Europe"

  sql_image_offer = "SQL2017-WS2016"
  sql_image_sku   = "Developer"

  wsfc_domain_profile {
    fqdn                = "testdomain.com"
    cluster_subnet_type = "SingleSubnet"
  }
}

resource "azurerm_mssql_virtual_machine" "example" {
  count = 2

  virtual_machine_id           = data.azurerm_virtual_machine.example[count.index].id
  sql_license_type             = "PAYG"
  sql_virtual_machine_group_id = azurerm_mssql_virtual_machine_group.example.id

  wsfc_domain_credential {
    cluster_bootstrap_account_password = "P@ssw0rd1234!"
    cluster_operator_account_password  = "P@ssw0rd1234!"
    sql_service_account_password       = "P@ssw0rd1234!"
  }
}

resource "azurerm_mssql_virtual_machine_availability_group_listener" "example" {
  name                         = "listener1"
  availability_group_name      = "availabilitygroup1"
  port                         = 1433
  sql_virtual_machine_group_id = azurerm_mssql_virtual_machine_group.example.id

  load_balancer_configuration {
    load_balancer_id   = data.azurerm_lb.example.id
    private_ip_address = "10.0.2.11"
    probe_port         = 51572
    subnet_id          = data.azurerm_subnet.example.id

    sql_virtual_machine_ids = [
      azurerm_mssql_virtual_machine.example[0].id,
      azurerm_mssql_virtual_machine.example[1].id
    ]
  }

  replica {
    sql_virtual_machine_id = azurerm_mssql_virtual_machine.example[0].id
    role                   = "Primary"
    commit                 = "Synchronous_Commit"
    failover               = "Automatic"
    readable_secondary     = "All"
  }

  replica {
    sql_virtual_machine_id = azurerm_mssql_virtual_machine.example[1].id
    role                   = "Secondary"
    commit                 = "Asynchronous_Commit"
    failover               = "Manual"
    readable_secondary     = "No"
  }
}

Arguments Reference

The following arguments are supported:


A load_balancer_configuration block supports the following:


A multi_subnet_ip_configuration block supports the following:


A replica block supports the following:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

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

Import

Microsoft SQL Virtual Machine Availability Group Listeners can be imported using the resource id, e.g.

terraform import azurerm_mssql_virtual_machine_availability_group_listener.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/vmgroup1/availabilityGroupListeners/listener1