Application gateway - rules- backend target change with REST/ logic app

Mazurek, Jakub 100 Reputation points
2025-04-03T13:23:53.11+00:00

hi!

I need a button to change the Application gateway - rules- backend target so I decided to go with the Logic app, I started working on in and am trying different REST http requests but none seem to be suited to the cause.

If I just get the appGW settings and just want to switch the target then the body is just huge and I'm getting lost in what to even change as there is a lot of fields that gets changed when I swap them manually and request the body again.

Is there some sort of easy guide to follow with that/ field to use?

Thanks in advance !

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,172 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Venkat V 1,485 Reputation points Microsoft External Staff
    2025-04-09T11:39:31.92+00:00

    Hi @Mazurek, Jakub

    The PUT request technically requires the full object to be included in the body.

    As tested in my environment, when using a limited set of values in the request body, I received the following error:
    User's image

    However, when I use the full configuration (as shown below), I'm able to successfully update the Application Gateway.

    {
      "location": "eastus",
      "tags": {
        "Environment": "Production"
      },
      "zones": [
        "1",
        "2",
        "3"
      ],
      "properties": {
        "sku": {
          "name": "Basic",
          "tier": "Basic",
          "capacity": 2
        },
        "enableHttp2": true,
        "gatewayIPConfigurations": [
          {
            "name": "appGatewayIpConfig",
            "properties": {
              "subnet": {
                "id": "/subscriptions/830e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/virtualNetworks/appgateway-vnet/subnets/default"
              }
            }
          }
        ],
        "frontendIPConfigurations": [
          {
            "name": "appGwPublicFrontendIpIPv4",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "/subscriptions/8332e60e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/publicIPAddresses/Venkat-pip"
              }
            }
          }
        ],
        "frontendPorts": [
          {
            "name": "port_80",
            "properties": {
              "port": 80
            }
          }
        ],
        "backendAddressPools": [
          {
            "name": "Venkat-pool",
            "properties": {
              "backendAddresses": []
            }
          },
          {
            "name": "Venkat-pool-2",
            "properties": {
              "backendAddresses": [
                {
                  "ipAddress": "10.0.0.15"
                },
                {
                  "ipAddress": "10.0.0.16"
                }
              ]
            }
          }
        ],
        "backendHttpSettingsCollection": [
          {
            "name": "Demo",
            "properties": {
              "port": 80,
              "protocol": "Http",
              "cookieBasedAffinity": "Disabled",
              "pickHostNameFromBackendAddress": false,
              "requestTimeout": 20
            }
          }
        ],
        "httpListeners": [
          {
            "name": "sample",
            "properties": {
              "frontendIPConfiguration": {
                "id": "/subscriptions/8332bf5e60e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/applicationGateways/venkat-appgateway/frontendIPConfigurations/appGwPublicFrontendIpIPv4"
              },
              "frontendPort": {
                "id": "/subscriptions/8332bf56-7e60e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/applicationGateways/venkat-appgateway/frontendPorts/port_80"
              },
              "protocol": "Http",
              "requireServerNameIndication": false
            }
          }
        ],
        "requestRoutingRules": [
          {
            "name": "demo-pool",
            "properties": {
              "ruleType": "Basic",
                "priority": 100,
              "httpListener": {
                "id": "/subscriptions/83320e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/applicationGateways/venkat-appgateway/httpListeners/sample"
              },
              "backendAddressPool": {
                "id": "/subscriptions/8332b60e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/applicationGateways/venkat-appgateway/backendAddressPools/Venkat-pool-2"
              },
              "backendHttpSettings": {
                "id": "/subscriptions/833260e5f09a9/resourceGroups/Venkat-RG/providers/Microsoft.Network/applicationGateways/venkat-appgateway/backendHttpSettingsCollection/Demo"
              }
            }
          }
        ]
      }
    }
    

    Output:User's image

    You can update the rule's backend target using just a CLI command

    az network application-gateway rule update -g MyResourceGroup --gateway-name MyAppGateway -n MyRule --http-listener MyNewBackendListener
    

    This is the simplest and safest method. No full JSON body required.

    If you want to use a Logic App, you can create an Automation Runbook with the above CLI cmdlet and integrate the Runbook into your Logic App, so that you can make the change through the Logic App.

    I hope this helps to resolve your issue. Please feel free to ask any questions if the solution provided isn't helpful.

    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.