我们有一个网络应用程序,在应用程序服务上配置了 Easy Auth,如图所示。因此所有请求都必须获得授权。
我们还在网络应用程序上启用了“始终在线”功能,因为我们希望保持底层网站始终处于活动状态。
但是,我们可以在
AppServiceHTTPLogs
日志表中看到,来自 AlwaysOn
用户代理的请求正在接收 401 状态代码。
我们的应用程序没有响应 401,因此 Always On 请求一定被 Easy Auth 功能拒绝。
我查看了这篇文章如何确保“始终开启”应用服务在 Azure AD 后面自动启动,该文章声称将
WEBSITE_WARMUP_PATH
设置为 /
将绕过该 url 的 Easy Auth,但这没有任何改变。此外,我们仍然希望对根的正常请求进行授权,但我们希望允许 Always On 请求实际到达应用程序。
我们如何实现这一目标?
该应用程序是 dotnet,在 Linux 应用程序服务计划上运行(如果这有什么区别的话)。
我创建了一个示例 ASP .Net Web API 应用程序并将其部署到 Azure Web 应用程序 (Linux)。
[AllowAnonymous]
属性。WarmupController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("api/[controller]")]
public class WarmupController : ControllerBase
{
requests.
[AllowAnonymous]
[HttpGet("warmup")]
public IActionResult Warmup()
{
return Ok("App is warmed up");
}
}
将应用程序部署到 Azure Web App 后,将环境变量设置为预热路由,如下所示。
这是没有任何错误的输出: