当功能应用程序禁用功能应用时,Azure API管理不会发送重试
如果第一个遇到错误,我已经配置了API管理策略,以重试到第二个区域。
但是,当我禁用基于悉尼的主函数应用程序时,应用程序见解中没有记录的重试 - 只有原始失败请求。墨尔本功能应用程序中没有记录函数调用。
我尝试了许多不同的配置。两个区域功能应用程序运行良好。
我已经复制了下面的代码,我缺少或不了解某些内容吗?
预先感谢
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>
403错误响应
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于在保存上有错误:
context.gariables.getValueordEfault&lt; int&gt;('retrycounter',0),0)
=&gt;( 我必须将单引号替换为双引号。context.variables.getValueordEfault&lt; int&gt;(“ retrycounter”,0)
用于测试我创建了两个模拟服务:
返回状态代码200:
httpps://rfqapiservicey27itmeb4cf7q.azure-azure-api.azure-api.azure-api.azure-api.azure-api.azure-api.azure-api.azure-api.azure-api.azure-api.azure-apo.azure-apo.azure-pechure/2 >
返回状态代码403:
https:// https://rfqapiservicey27itmeb4cf7q.azure-azure-azure-echure-echure-echure-apoi teast/403 >
重试
后端
部分将永远不会返回到inbound
部分。因此,选择
条件仅在一开始就受到打击。因此,
选择
条件必须移至后端
部分。我的示例操作按预期执行:
backend
请求请求403资源:此请求失败,
重试
策略在Backend
e节:当将返回 200 并留下
后端
部分:I had to replace the single quotes to double quotes because of an error on save:
context.Variables.GetValueOrDefault<int>('RetryCounter', 0)
=>context.Variables.GetValueOrDefault<int>("RetryCounter", 0)
For testing I created two mocked services:
Returns status code 200:
https://rfqapiservicey27itmeb4cf7q.azure-api.net/echo/200/test
Returns status code 403:
https://rfqapiservicey27itmeb4cf7q.azure-api.net/echo/403/test
The
retry
section in thebackend
section will never return to theinbound
section. So thechoose
condition was only hit at the very beginning.Therefore, the
choose
condition has to be moved to thebackend
section.My sample operation executes as expected:
https://rfqapiservicey27itmeb4cf7q.azure-api.net/sample/test
The first hit in the

backend
requests the 403 resource:This request is failing, and the

retry
policy sets the 200 in thebackend
section:This second request is successful when will return 200 and leave the
backend
section: