Use Azure Api Management as a passthrough

后端 未结 2 947
难免孤独
难免孤独 2021-01-05 06:08

I would like to create a policy in Azure API Management that forwards all calls that start with the path \"proxy/search\" to another url. However, i don\'t want to have to i

相关标签:
2条回答
  • 2021-01-05 06:39

    You are making your life much harder than it needs to be. Simply create an operation that uses /proxy/* as the template and it will match to all the URLs you identified.

    Then just create a policy for that operation that does set-backend-service.

    0 讨论(0)
  • 2021-01-05 06:42

    Adding to Darrel Miller's answer, here is how i got it working...

    Adding an operation...

    {
      "name": "Search_GET",
      "method": "GET",
      "urlTemplate": "/search/*",
      "policies": null
    }       
    

    Adding a policy for that operation...

    <policies>
        <inbound>
            <base />
            <set-backend-service base-url="https://mysearchapi.com/" />
            <rewrite-uri template="@(context.Request.Url.Path.Replace("search/", ""))" />
            <set-header name="Api-Version" exists-action="skip">
                <value>1.0</value>
            </set-header>
        </inbound>
        <outbound>
            <base />
        </outbound>
    </policies>
    
    0 讨论(0)
提交回复
热议问题