Cannot connect to Application Service from the Application Gateway when Private endpoints and Virtual Network Integration

Morgan Ecklund 0 Reputation points
2025-02-16T16:09:08.01+00:00

Cannot connect to Application Service from the Application Gateway when Private endpoints and Virtual Network Integration

Application Gateway give 502 error

Azure Firewall
Azure Firewall
An Azure network security service that is used to protect Azure Virtual Network resources.
727 questions
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,654 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,136 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Prasanna Sinde 4,260 Reputation points Microsoft External Staff
    2025-02-17T05:04:38.58+00:00

    Hi @Morgan Ecklund

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

    In addition to the solution provided above by @Vidya Viraktamath , I wanted to add a few more details.

    Make sure the NSG associated with the Application Gateway subnet allows outbound traffic to the private IP address of your Application Service on the port it's listening on (443 for HTTPS) and also verify the NSG on the Application Service subnet allows inbound traffic from the Application Gateway subnet on the service port. Please refer this document.

    If you have a UDR on the Application Gateway subnet, make sure it's not inadvertently routing traffic destined for the Application Service to an incorrect location. The route for the Application Service's private IP range should point directly to the virtual network or have a more specific route. Please refer this document.

    The Application Gateway needs to resolve the private FQDN of your Application Service to its private IP address. Make sure that the Application Gateway is using a DNS server that can resolve private DNS records within your virtual network.

    The presence of a custom DNS in the VNet could also cause issues. An FQDN used for backend pool members might not resolve correctly by the user configured DNS server for the VNet.

    Check that the health probes configured on your Application Gateway are correctly set up and are able to reach your Application Service. If the probes are failing, the Application Gateway will mark the backend as unhealthy and return 502 errors.

    Make sure the Private Endpoint for your Application Service is correctly configured and associated with the correct subnet and also verify that the private DNS zone for your Application Service has the necessary A records that map the service's FQDN to the private IP address of the Private Endpoint.

    Also use the "Effective Security Rules" feature in the Azure portal to check the actual NSG rules that are applied to the Application Gateway and Application Service subnets.

    Enable diagnostic logging for your Application Gateway and analyze the logs for any errors or clues related to the 502 error. Check the logs of your Application Service for any errors or exceptions.

    References: Troubleshooting bad gateway errors in Application Gateway

    Please refer to this document for additional reference and see if it works for you.


    Kindly let us know if the above helps or you need further assistance on this issue.


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.