Hi I am trying to implement such a functionality where i need to make sure that the api is going through gateway so have created a apim and i need to extract header from the call and route to that call : so far i have done this policy:
<policies>
<inbound>
<set-variable name="host" value="@(context.Request.Headers.GetValueOrDefault("uri","http://google.com/"))" />
<set-backend-service base-url="${{ variables.host}}" />
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
but its giving error :
Error in element 'set-backend-service' on line 16, column 4: Value is not a valid absolute URL.
CodePudding user response:
To resolve this issue, there are two things to do:
Define the parameter type you are using in the template file.
When defining param's you need to signify the start and end of the command using square brackets.
Try this:
<set-backend-service base-url=\"[parameters('backend_url')]\"/>
Refer this document to know about parameters in ARM templates.
CodePudding user response:
<set-backend-service base-url="@((string)context.Variables["host"])" />