<p>I have deployed the standard aspnet app from Microsoft, from the following YAML:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: microservicesapp
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: aspnetapp
          servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: aspnetapp
spec:
  selector:
    app: aspnetapp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
---
apiVersion: v1
kind: Pod
metadata:
  name: aspnetapp
  labels:
    app: aspnetapp
spec:
  containers:
  - image: &quot;mcr.microsoft.com/dotnet/core/samples:aspnetapp&quot;
    name: aspnetapp-image
    ports:
    - containerPort: 80
      protocol: TCP
</code></pre>
<p>Everything works fine when I call the public IP associated with my AGW resourced. However, I want to configure the path of the ingress, so that it is <code>/test</code>. Like so:</p>
<pre><code>  - http:
      paths:
      - path: /test
        backend:
          serviceName: aspnetapp
          servicePort: 80
</code></pre>
<p>When I attempt to call the endpoint from outside the cluster, this results in 502 Bad Gateway. The Controller logs after deployment of the resources in the above YAML:</p>
<pre><code>I0918 17:25:16.798265       1 health_probes.go:55] Created default HTTP probe defaultprobe-Http
I0918 17:25:16.798272       1 health_probes.go:56] Created default HTTPS probe defaultprobe-Http
I0918 17:25:16.798279       1 ingress_rules.go:148] Found backend:default/aspnetapp
I0918 17:25:16.798405       1 health_probes.go:70] Created probe pb-default-aspnetapp-80-microservicesapp for ingress default/microservicesapp at service default/aspnetapp
I0918 17:25:16.798613       1 backendhttpsettings.go:190] Created backend http settings bp-default-aspnetapp-80-80-microservicesapp for ingress default/microservicesapp and service default/aspnetapp
I0918 17:25:16.798671       1 backendaddresspools.go:37] Created default backend pool defaultaddresspool
I0918 17:25:16.798698       1 backendaddresspools.go:48] Created backend pool pool-default-aspnetapp-80-bp-80 for service default/aspnetapp
I0918 17:25:16.798709       1 frontend_listeners.go:121] Processing Rules for Ingress: default/microservicesapp
I0918 17:25:16.798828       1 requestroutingrules.go:349] Attached pool pool-default-aspnetapp-80-bp-80 and http setting bp-default-aspnetapp-80-80-microservicesapp to path rule: pr-default-microservicesapp-0
I0918 17:25:16.798861       1 requestroutingrules.go:107] Bound path-based rule: rr-e1903c8aa3446b7b3207aec6d6ecba8a to listener: fl-e1903c8aa3446b7b3207aec6d6ecba8a ([    ], 80) and url path map url-e1903c8aa3446b7b3207aec6d6ecba8a
I0918 17:25:16.808144       1 mutate_app_gateway.go:174] Generated config:
...
</code></pre>
<p>What is the correct way to set a path, like <code>/test</code>, so that all traffic to that path, is directed to the aspnetapp service?</p>

Mike Hawkins
<p>Add path prefix annotation <code>appgw.ingress.kubernetes.io/backend-path-prefix: &quot;/&quot;</code> in the ingress resource.The annotation tells application gateway to create an HTTP setting which will have a path prefix override for the path <code>/test</code> to <code>/</code></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: microservicesapp
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/backend-path-prefix: &quot;/&quot;
spec:
  rules:
  - http:
      paths:
      - path: /test
        backend:
          serviceName: aspnetapp
          servicePort: 80
</code></pre>
