![](/img/trans.png)
[英]Async IP restricted Logic App with Azure API Management gives authorization error when calling retry url
[英]Azure API management not sending retry when function app disabled
如果第一个区域遇到错误,我已配置 API 管理策略以重试到第二个区域。
但是,当我禁用位于悉尼的主要功能应用程序时,应用程序洞察中没有记录重试 - 只有原始失败请求。 墨尔本函数应用程序中没有记录函数调用。
我尝试了很多不同的配置。 两个区域功能应用程序都运行良好。
我已经复制了下面的代码,有什么我遗漏或不理解的地方吗?
提前致谢
<policies>
<inbound>
<base />
<choose>
<when condition="@(context.Variables.GetValueOrDefault<int>('RetryCounter', 0) == 0)">
<set-backend-service base-url="{{syndey-function-app}}" />
</when>
<otherwise>
<set-backend-service base-url="{{melbourne-function-app}}" />
</otherwise>
</choose>
</inbound>
<backend>
<retry count="1" interval="0" first-fast-retry="true" condition="@(
context.Response.StatusCode > 400
)">
<set-variable name="RetryCounter" value="@(context.Variables.GetValueOrDefault<int>('RetryCounter', 0) + 1)" />
<forward-request buffer-request-body="true" timeout="15"/>
</retry>
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
<h1 id="unavailable">Error 403 - This web app is stopped.</h1>
<p id="tryAgain">
The web app you have attempted to reach is currently stopped and does not
accept any requests. Please try to reload the page or visit it again soon.
</p>
<p id="toAdmin">
If you are the web app administrator, please find the common 403 error
scenarios and resolution <a href="https://go.microsoft.com/fwlink/?linkid=2095007"
target="_blank">here</a>. For further troubleshooting tools and recommendations,
please visit <a href="https://portal.azure.com/">Azure Portal</a>.
</p>
由于保存时出错,我不得不将单引号替换为双引号:
context.Variables.GetValueOrDefault<int>('RetryCounter', 0)
=> context.Variables.GetValueOrDefault<int>("RetryCounter", 0)
为了测试,我创建了两个模拟服务:
返回状态码 200:
https://rfqapiservicey27itmeb4cf7q.azure-api.net/echo/200/test
返回状态码 403:
https://rfqapiservicey27itmeb4cf7q.azure-api.net/echo/403/test
backend
部分的retry
部分永远不会返回inbound
部分。 所以choose
条件只是在一开始就被击中。
因此,必须将choose
条件移至backend
部分。
<policies>
<inbound>
<base />
<set-backend-service base-url="https://rfqapiservicey27itmeb4cf7q.azure-api.net/echo/403" />
<!--
<set-backend-service base-url="{{syndey-function-app}}" />
-->
</inbound>
<backend>
<retry count="1" interval="0" first-fast-retry="true" condition="@(
context.Response.StatusCode > 400
)">
<set-variable name="RetryCounter" value="@(context.Variables.GetValueOrDefault<int>("RetryCounter", 0) + 1)" />
<choose>
<when condition="@(context.Variables.GetValueOrDefault<int>("RetryCounter", 0) > 1)">
<set-backend-service base-url="https://rfqapiservicey27itmeb4cf7q.azure-api.net/echo/200" />
<!--
<set-backend-service base-url="{{melbourne-function-app}}" />
-->
</when>
</choose>
<forward-request buffer-request-body="true" timeout="15" />
</retry>
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
我的示例操作按预期执行:
https://rfqapiservicey27itmeb4cf7q.azure-api.net/sample/test
此请求失败, retry
策略在backend
部分设置200 :
第二个请求成功时将返回200并离开backend
部分:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.