Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow Application Gateway Backend pool pointing at a specific VM

How do we add virtual machine as target in backend pool of an Application Gateway using terraform code ?

enter image description here

What property I should use in the following code to point at particular virtual Machine ?

    resource "azurerm_application_gateway" "network" {
  name                = "example-appgateway"
  resource_group_name = "${azurerm_resource_group.test.name}"
  location            = "${azurerm_resource_group.test.location}"

  sku {
    name     = "Standard_Small"
    tier     = "Standard"
    capacity = 2
  }

  gateway_ip_configuration {
    name      = "my-gateway-ip-configuration"
    subnet_id = "${azurerm_subnet.frontend.id}"
  }

  frontend_port {
    name = "${local.frontend_port_name}"
    port = 80
  }

  frontend_ip_configuration {
    name                 = "${local.frontend_ip_configuration_name}"
    public_ip_address_id = "${azurerm_public_ip.test.id}"
  }

  backend_address_pool {
    name = "${local.backend_address_pool_name}"
  }

  backend_http_settings {
    name                  = "${local.http_setting_name}"
    cookie_based_affinity = "Disabled"
    port                  = 80
    protocol              = "Http"
    request_timeout       = 1
  }

  http_listener {
    name                           = "${local.listener_name}"
    frontend_ip_configuration_name = "${local.frontend_ip_configuration_name}"
    frontend_port_name             = "${local.frontend_port_name}"
    protocol                       = "Http"
  }

  request_routing_rule {
    name                       = "${local.request_routing_rule_name}"
    rule_type                  = "Basic"
    http_listener_name         = "${local.listener_name}"
    backend_address_pool_name  = "${local.backend_address_pool_name}"
    backend_http_settings_name = "${local.http_setting_name}"
  }
}

The backend_address_pool block supports:

  • name - (Required) User defined name for a backend address pool.
  • ip_addresses - (Optional) List of public IPAdresses, or internal IP addresses in a backend address pool.
  • fqdns - (Optional) List of FQDNs in a backend address pool
like image 733
Kundan Kumar Avatar asked Oct 14 '25 07:10

Kundan Kumar


1 Answers

If someone will be looking at adding App Service to backend. This is following what you need to do:

backend_address_pool {
  name = local.backend_address_pool_name
  fqdns = ["${azurerm_function_app.function_app.name}.azurewebsites.net"]
}
like image 71
Marcin Dudek Avatar answered Oct 17 '25 00:10

Marcin Dudek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!