How to add VMSS as a backend target type using az cli command?

Raja, Vijay 5 Reputation points
2024-08-09T22:56:34.1966667+00:00

I am trying to update the backend with VMSS, but encountering this error:

ERROR: (ApplicationGatewayBackendAddressMustHaveEitherFqdnOrIpAddress) Backend Address Pool newpassmetScaleSet-1723238703-backend must have either Fqdn or IpAddress specified.

Code: ApplicationGatewayBackendAddressMustHaveEitherFqdnOrIpAddress

How can I fix this issue?

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,401 questions
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,048 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rohith Vinnakota 315 Reputation points Microsoft Vendor
    2024-08-21T13:48:39.54+00:00

    Hi Raja, Vijay

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

     Azure Application Gateway does not natively support directly adding a VMSS as a backend target by its resource ID. Instead, you need to associate the IP addresses of the VM instances within the VMSS or, alternatively, use a Public or Internal Load Balancer that fronts the VMSS as the backend target.

     

    Here are the steps to properly configure the Application Gateway backend pool with a VMSS using Azure CLI:

    Option 1: Adding a VMSS by IP Address Or FQDN

    1. Retrieve the IP addresses of the VM instances in the VMSS. This can be done using the Azure CLI or through the Azure portal.

     

    command to list IP addresses:

    az vmss nic list \
       --resource-group Rohith-RG \
       --vmss-name vmss-01 \
       --query "[].ipConfigurations[].privateIpAddress" \
       --output tsv
    

     

    2.Add these IP addresses to the Application Gateway backend pool:

    az network application-gateway address-pool update \
       --resource-group Rohith-RG \
       --gateway-name app-gateway-01 \
       --name backpoo-end \
       --add backendAddresses ipAddress=XX.XX.XX.XX ipAddress=YY.YY.YY.YY
    

     

    Replace XX.XX.XX.XX and YY.YY.YY.YY with the actual IP addresses of your VM instances.

    3.Add the FQDN to the Application Gateway backend pool:

     

    az network application-gateway address-pool update \
        --resource-group MyResourceGroup \
        --gateway-name MyAppGateway \
        --name MyBackendPool \
        --add backendAddresses fqdn=myapp.contoso.com
    

     

    Option 2: Using a Load Balancer with VMSS

    1. Create an Azure Load Balancer (if not already done) and associate it with your VMSS.
    2. Add the Load Balancer's IP address as the backend for the Application Gateway:
    az network application-gateway address-pool update \
       --resource-group Rohith-RG \
       --gateway-name app-gateway-01 \
       --name backpoo-end \
       --add backendAddresses ipAddress=ZZ.ZZ.ZZ.ZZ
    

    Replace ZZ.ZZ.ZZ.ZZ with the Load Balancer’s frontend IP address.

    Note:

    By providing the IP addresses of the VMSS instances or using a Load Balancer, the Application Gateway can be properly configured to route traffic to the VMSS.

     

    For details, refer to az network application-gateway address-pool | Microsoft Learn

    If you have any further queries, do let us know. If the answer is helpful, please click "Accept Answer" and "Upvote it."

    0 comments No comments

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.