Self-Chained APIM request limitation in internal Virtual network mode (Developer and Premium tier)

Published Nov 30 2020 05:38 AM 1,204 Views
Microsoft

Known Issue

When you are running API Management instance in “internal” Virtual network mode and trying to call APIs hosted in the same APIM service (use APIM gateway endpoint Url as backend Url), you may experience 500 errors with “BackendConnectionFailure”.

 

Below screenshots demonstrate the steps to reproduce this issue.

  1. Define Recursion API/operation configuration in APIM instance. Here we let APIM forward http request https://proxy.momorin.com/recursion/echo/resource to https://proxy.momorin.com/echo/resource, which is API in the same APIM instance:

image001.png

  1. Try to send request through Postman, we need allow inspector trace to better troubleshoot. As a result, 500 error returned after 21 seconds.

image003.png

  1. Now check the APIM inspector trace for more detailed information. We can get trace url from response header “Ocp-Apim-Trace-Location”.

image005.png

  1. As you can see in the inspector trace, the error happens at backend level, when trying to forward request to APIM itself. Error message is “Unable to connect to the remote server”.

image007.pngimage009.png

You checked all the network configurations, there are no NSG or force tunneling blocking the traffic from internal VNet to APIM gateway endpoint, or even though you logged into one VM inside the same VNet, the connection from this VM to APIM gateway endpoint still works well.

 

It’s very confusing, because you may just send a call without any other policy or any other configurations related to the backend Url and it should not fail, as the first request layer with same domain succeeded.

 

Internal Load Balancer Limitation

The root cause of this issue is the load balancer limitation when accessing the internal Load Balancer frontend from the participating Load Balancer backend pool VM, as documented here:

https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-troubleshoot-backend-traffic#caus....

 

When deploying APIM service into internal VNet mode, the load balancer of gateway (proxy) endpoint is in the same subnet where APIM backend instances are deployed in.

image011.jpg

If an internal Load Balancer is configured inside a VNet, and one of the participant backend VMs is trying to access the internal Load Balancer frontend, failures can occur when the flow is mapped to the originating VM (same VM). This scenario is not supported.

 

If you use APIM Premium tier, you will have at least two VMs in the subnet, so this issue may intermittently happen (traffic from instance 1 to instance2 will succeed, traffic from instance 1 back to instance 1 will fail). But if you are using Developer pricing tier, you only have one VM instance in the APIM backend pool, this issue will consistently occur.

 

Historically for Internal VNET mode, APIM used to override environment level DNS on the APIM VMs for Gateway hostnames (default and custom ones) to map them to loopback interface (127.0.0.1) using host file entries on the VMs so that every time Gateway (or any other software on the VM) tried to call one of these hostnames, it would connect to itself through loopback network interface defined in the host file.

 

After an update in February 2020, a decision was made to stop doing host file DNS overrides. This change caused outgoing traffic from APIM VM to its own hostname to be routed to APIM Load Balancer instead of loopback interface. As a result, API calls that were sent to the same APIM service via forward-request or send-request policies started failing.

 

Resolution

The best solution for this issue is to change the Url of the API in the policy to https://127.0.0.1 *and* add a “host” header to the request for the desired proxy host.image012.jpg

APIM proxy can send requests to backend (including itself) using forward-request or send-request policies. Below are the solutions for each kind of policy.

 

Change Url of forward-request policy

 

If the failing request is being sent via forward-request policy (the backendUrl of the API has been set as the Url of the APIM Proxy), the hostname of backendUrl should be changed to https://127.0.0.1. Additionally, a set-header policy should be added in <inbound> section to add the desired host header (which previously used to be part of the Url):

 

 

<policies>
    <inbound>
        <set-header name="Host" exists-action="override">
            <value>proxy.momorin.com</value>
        </set-header>
    </inbound>
    <backend>
        <forward-request />
    </backend>
</policies>

 

 

 

Below is one simple instruction & test result of this resolution:

image013.png

 

200OK returned from https://proxy.momorin.com/recursion/echo/resource this time.

image015.png

The forwarding url is https://127.0.0.1/echo/resource with host “proxy.momorin.com”.

image017.png

 

Or we can apply the following in the global scope (All APIs) so that we don’t need to modify each API in the backend Url.

 

 

    <inbound>
        <choose>
            <when condition="@(context.Request.Url.ToString().Contains("proxy.momorin.com"))">
                <set-header name="Host" exists-action="override">
                    <value>proxy.momorin.com</value>
                </set-header>
                <set-backend-service base-url="@(context.Request.OriginalUrl.Scheme.ToString() + "://127.0.0.1")" />
            </when>
        </choose>
    </inbound>

 

 

 

Change Url of send-request policy

If APIM is called using send-request policy, host can be added directly inside the policy:

 

 

<send-request>
    <set-url>https://127.0.0.1/echo/resource</set-url>
    <set-header name="Host">
        <value>proxy.momorin.com</value>
    </set-header>
</send-request>

 

 

 

 

 

 

1 Comment
Occasional Visitor

I have a different opinion on the best solution to the problem above. Instead of having to change APIM policies to point explicitly to localhost; azure application gateway can be used as suggested here, which solves that problem and have other important benefits.

 

Regardless whether APIM is in internal or external mode, we found it important to map APIM custom domains to azure application gateway first (which supports both internal and external frontend IPs). This has the benefits of WAF (Web application firewall) when needed and will also deal with situations where you want to open up certain APIs externally, while keeping others private.

%3CLINGO-SUB%20id%3D%22lingo-sub-1940417%22%20slang%3D%22en-US%22%3ESelf-Chained%20APIM%20request%20limitation%20in%20internal%20Virtual%20network%20mode%20(Developer%20and%20Premium%20tier)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1940417%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EKnown%20Issue%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWhen%20you%20are%20running%20API%20Management%20instance%20in%20%E2%80%9Cinternal%E2%80%9D%20Virtual%20network%20mode%20and%20trying%20to%20call%20APIs%20hosted%20in%20the%20same%20APIM%20service%20(use%20APIM%20gateway%20endpoint%20Url%20as%20backend%20Url)%2C%20you%20may%20experience%3CSTRONG%3E%20500%20%3C%2FSTRONG%3Eerrors%20with%20%E2%80%9CBackendConnectionFailure%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20screenshots%20demonstrate%20the%20steps%20to%20reproduce%20this%20issue.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EDefine%20Recursion%20API%2Foperation%20configuration%20in%20APIM%20instance.%20Here%20we%20let%20APIM%20forward%20http%20request%20%3CA%20href%3D%22https%3A%2F%2Fproxy.momorin.com%2Frecursion%2Fecho%2Fresource%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CEM%3Ehttps%3A%2F%2Fproxy.momorin.com%2Frecursion%2Fecho%2Fresource%3C%2FEM%3E%3C%2FA%3E%20to%20%3CA%20href%3D%22https%3A%2F%2Fproxy.momorin.com%2Fecho%2Fresource%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CEM%3Ehttps%3A%2F%2Fproxy.momorin.com%2Fecho%2Fresource%3C%2FEM%3E%3C%2FA%3E%2C%20which%20is%20API%20in%20the%20same%20APIM%20instance%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image001.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236627i0DE8896B55960344%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image001.png%22%20alt%3D%22image001.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3ETry%20to%20send%20request%20through%20Postman%2C%20we%20need%20allow%20inspector%20trace%20to%20better%20troubleshoot.%20As%20a%20result%2C%20500%20error%20returned%20after%2021%20seconds.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image003.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236628i959A1969438DF2F6%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image003.png%22%20alt%3D%22image003.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%223%22%3E%0A%3CLI%3ENow%20check%20the%20APIM%20inspector%20trace%20for%20more%20detailed%20information.%20We%20can%20get%20trace%20url%20from%20response%20header%20%E2%80%9COcp-Apim-Trace-Location%E2%80%9D.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image005.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236629i157723674C8A499F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image005.png%22%20alt%3D%22image005.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%224%22%3E%0A%3CLI%3EAs%20you%20can%20see%20in%20the%20inspector%20trace%2C%20the%20error%20happens%20at%20backend%20level%2C%20when%20trying%20to%20forward%20request%20to%20APIM%20%3CSTRONG%3Eitself%3C%2FSTRONG%3E.%20Error%20message%20is%20%E2%80%9CUnable%20to%20connect%20to%20the%20remote%20server%E2%80%9D.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image007.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236631iF5367E6A532FB787%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image007.png%22%20alt%3D%22image007.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image009.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236630i542155DBA1401624%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image009.png%22%20alt%3D%22image009.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20checked%20all%20the%20network%20configurations%2C%20there%20are%20no%20NSG%20or%20force%20tunneling%20blocking%20the%20traffic%20from%20internal%20VNet%20to%20APIM%20gateway%20endpoint%2C%20or%20even%20though%20you%20logged%20into%20one%20VM%20inside%20the%20same%20VNet%2C%20the%20connection%20from%20this%20VM%20to%20APIM%20gateway%20endpoint%20still%20works%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20very%20confusing%2C%20because%20you%20may%20just%20send%20a%20call%20without%20any%20other%20policy%20or%20any%20other%20configurations%20related%20to%20the%20backend%20Url%20and%20it%20should%20not%20fail%2C%20as%20the%20first%20request%20layer%20with%20same%20domain%20succeeded.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EInternal%20Load%20Balancer%20Limitation%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20root%20cause%20of%20this%20issue%20is%20the%20load%20balancer%20limitation%20when%20accessing%20the%20internal%20Load%20Balancer%20frontend%20from%20the%20participating%20Load%20Balancer%20backend%20pool%20VM%2C%20as%20documented%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fload-balancer%2Fload-balancer-troubleshoot-backend-traffic%23cause-4-accessing-the-internal-load-balancer-frontend-from-the-participating-load-balancer-backend-pool-vm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fload-balancer%2Fload-balancer-troubleshoot-backend-traffic%23cause-4-accessing-the-internal-load-balancer-frontend-from-the-participating-load-balancer-backend-pool-vm%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20deploying%20APIM%20service%20into%20internal%20VNet%20mode%2C%20the%20load%20balancer%20of%20gateway%20(proxy)%20endpoint%20is%20in%20the%20same%20subnet%20where%20APIM%20backend%20instances%20are%20deployed%20in.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image011.jpg%22%20style%3D%22width%3A%20456px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236632i7626C4696C7471E8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image011.jpg%22%20alt%3D%22image011.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIf%20an%20internal%20Load%20Balancer%20is%20configured%20inside%20a%20VNet%2C%20and%20one%20of%20the%20participant%20backend%20VMs%20is%20trying%20to%20access%20the%20internal%20Load%20Balancer%20frontend%2C%20failures%20can%20occur%20when%20the%20flow%20is%20mapped%20to%20the%20originating%20VM%20(same%20VM).%20This%20scenario%20is%20not%20supported.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20use%20APIM%20Premium%20tier%2C%20you%20will%20have%20at%20least%20two%20VMs%20in%20the%20subnet%2C%20so%20this%20issue%20may%20intermittently%20happen%20(traffic%20from%20instance%201%20to%20instance2%20will%20succeed%2C%20traffic%20from%20instance%201%20back%20to%20instance%201%20will%20fail).%20But%20if%20you%20are%20using%20Developer%20pricing%20tier%2C%20you%20only%20have%20one%20VM%20instance%20in%20the%20APIM%20backend%20pool%2C%20this%20issue%20will%20consistently%20occur.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHistorically%20for%20Internal%20VNET%20mode%2C%20APIM%20used%20to%20override%20environment%20level%20DNS%20on%20the%20APIM%20VMs%20for%20Gateway%20hostnames%20(default%20and%20custom%20ones)%20to%20map%20them%20to%20loopback%20interface%20(127.0.0.1)%20using%20host%20file%20entries%20on%20the%20VMs%20so%20that%20every%20time%20Gateway%20(or%20any%20other%20software%20on%20the%20VM)%20tried%20to%20call%20one%20of%20these%20hostnames%2C%20it%20would%20connect%20to%20itself%20through%20loopback%20network%20interface%20defined%20in%20the%20host%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20an%20update%20in%20February%202020%2C%20a%20decision%20was%20made%20to%20stop%20doing%20host%20file%20DNS%20overrides.%20This%20change%20caused%20outgoing%20traffic%20from%20APIM%20VM%20to%20its%20own%20hostname%20to%20be%20routed%20to%20APIM%20Load%20Balancer%20instead%20of%20loopback%20interface.%20As%20a%20result%2C%20API%20calls%20that%20were%20sent%20to%20the%20same%20APIM%20service%20via%20forward-request%20or%20send-request%20policies%20started%20failing.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EResolution%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20best%20solution%20for%20this%20issue%20is%20to%20change%20the%20Url%20of%20the%20API%20in%20the%20policy%20to%20%3CA%20href%3D%22https%3A%2F%2F127.0.0.1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2F127.0.0.1%3C%2FA%3E%20*%3CSTRONG%3Eand%3C%2FSTRONG%3E*%20add%20a%20%E2%80%9Chost%E2%80%9D%20header%20to%20the%20request%20for%20the%20desired%20proxy%20host.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image012.jpg%22%20style%3D%22width%3A%20456px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236633iEB20E934B9D07E39%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image012.jpg%22%20alt%3D%22image012.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAPIM%20proxy%20can%20send%20requests%20to%20backend%20(including%20itself)%20using%20forward-request%20or%20send-request%20policies.%20Below%20are%20the%20solutions%20for%20each%20kind%20of%20policy.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EChange%20Url%20of%20%3C%2FSTRONG%3E%3CSTRONG%3Eforward-request%20policy%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20failing%20request%20is%20being%20sent%20via%20forward-request%20policy%20(the%20backendUrl%20of%20the%20API%20has%20been%20set%20as%20the%20Url%20of%20the%20APIM%20Proxy)%2C%20the%20hostname%20of%20backendUrl%20should%20be%20changed%20to%20%3CU%3E%3CA%20href%3D%22https%3A%2F%2F127.0.0.1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2F127.0.0.1%3C%2FA%3E%3C%2FU%3E.%20Additionally%2C%20a%20set-header%20policy%20should%20be%20added%20in%20%3CINBOUND%3E%20section%20to%20add%20the%20desired%20host%20header%20(which%20previously%20used%20to%20be%20part%20of%20the%20Url)%3A%3C%2FINBOUND%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%3CPOLICIES%3E%0A%20%20%20%20%3CINBOUND%3E%0A%20%20%20%20%20%20%20%20%3CSET-HEADER%20name%3D%22Host%22%20exists-action%3D%22override%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CVALUE%3Eproxy.momorin.com%3C%2FVALUE%3E%0A%20%20%20%20%20%20%20%20%3C%2FSET-HEADER%3E%0A%20%20%20%20%3C%2FINBOUND%3E%0A%20%20%20%20%3CBACKEND%3E%0A%20%20%20%20%20%20%20%20%3CFORWARD-REQUEST%3E%3C%2FFORWARD-REQUEST%3E%0A%20%20%20%20%3C%2FBACKEND%3E%0A%3C%2FPOLICIES%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20is%20one%20simple%20instruction%20%26amp%3B%20test%20result%20of%20this%20resolution%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image013.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236634i96C89632DCAD5454%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image013.png%22%20alt%3D%22image013.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E200OK%20returned%20from%20%3CA%20href%3D%22https%3A%2F%2Fproxy.momorin.com%2Frecursion%2Fecho%2Fresource%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CEM%3Ehttps%3A%2F%2Fproxy.momorin.com%2Frecursion%2Fecho%2Fresource%3C%2FEM%3E%3C%2FA%3E%20this%20time.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image015.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236635iBB730B25A5B8FC86%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image015.png%22%20alt%3D%22image015.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20forwarding%20url%20is%20%3CA%20href%3D%22https%3A%2F%2F127.0.0.1%2Fecho%2Fresource%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2F127.0.0.1%2Fecho%2Fresource%3C%2FA%3E%20with%20host%20%E2%80%9Cproxy.momorin.com%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image017.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236636iE5E3D62E8AB116F8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image017.png%22%20alt%3D%22image017.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOr%20we%20can%20apply%20the%20following%20in%20the%20global%20scope%20(All%20APIs)%20so%20that%20we%20don%E2%80%99t%20need%20to%20modify%20each%20API%20in%20the%20backend%20Url.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%20%20%20%20%3CINBOUND%3E%0A%20%20%20%20%20%20%20%20%3CCHOOSE%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CWHEN%20condition%3D%22%40(context.Request.Url.ToString().Contains(%22%20proxy.momorin.com%3D%22%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSET-HEADER%20name%3D%22Host%22%20exists-action%3D%22override%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CVALUE%3Eproxy.momorin.com%3C%2FVALUE%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2FSET-HEADER%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSET-BACKEND-SERVICE%20base-url%3D%22%40(context.Request.OriginalUrl.Scheme.ToString()%20%2B%20%22%3E%3C%2FSET-BACKEND-SERVICE%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3C%2FWHEN%3E%0A%20%20%20%20%20%20%20%20%3C%2FCHOOSE%3E%0A%20%20%20%20%3C%2FINBOUND%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EChange%20Url%20of%3C%2FSTRONG%3E%3CSTRONG%3E%20send-request%20policy%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIf%20APIM%20is%20called%20using%20send-request%20policy%2C%20host%20can%20be%20added%20directly%20inside%20the%20policy%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%3CSEND-REQUEST%3E%0A%20%20%20%20%3CSET-URL%3Ehttps%3A%2F%2F127.0.0.1%2Fecho%2Fresource%3C%2FSET-URL%3E%0A%20%20%20%20%3CSET-HEADER%20name%3D%22Host%22%3E%0A%20%20%20%20%20%20%20%20%3CVALUE%3Eproxy.momorin.com%3C%2FVALUE%3E%0A%20%20%20%20%3C%2FSET-HEADER%3E%0A%3C%2FSEND-REQUEST%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1940417%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20you%20are%20running%20API%20Management%20instance%20in%20%E2%80%9Cinternal%E2%80%9D%20Virtual%20network%20mode%20and%20trying%20to%20call%20APIs%20hosted%20in%20the%20same%20APIM%20service%20(use%20APIM%20gateway%20endpoint%20Url%20as%20backend%20Url)%2C%20you%20may%20experience%3CSTRONG%3E%20500%20%3C%2FSTRONG%3Eerrors%20with%20%E2%80%9CBackendConnectionFailure%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image011.jpg%22%20style%3D%22width%3A%20456px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236639i864806594591C0C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image011.jpg%22%20alt%3D%22image011.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1940417%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20API%20management%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Feb 05 2021 05:45 AM
Updated by: