托管服务身份必须配置为使用身份验证令牌策略

Managed service identity must be configured to use authentication-token policy

我正在尝试让我的后端 API 验证请求来自 Azure APIM 使用托管身份,以前这是通过证书身份验证完成的,但出于各种原因我正在寻找改变这一点。

当我向 APIM 发出请求时,我在应用程序洞察中收到以下错误。

Managed service identity must be configured to use authentication-token policy.

在后端,我使用的是 Owin 的 Windows Azure Active Directory 承载身份验证。

app.UseWindowsAzureActiveDirectoryBearerAuthentication(
    new WindowsAzureActiveDirectoryBearerAuthenticationOptions
    {
        Tenant = "https://tennant.co.uk/AzureADDAuth",
        TokenValidationParameters = new TokenValidationParameters
        {
            ValidAudience = "11111111-1111-1111-1111-111111111111"
        },
    });

在APIM入站政策如下

<authentication-managed-identity resource="https://tennant.co.uk/AzureAADAuth" client-id="11111111-1111-1111-1111-111111111111" output-token-variable-name="msi-access-token" ignore-error="false" />
<set-header name="Authorization" exists-action="override">
    <value>@("Bearer " + (string)context.Variables["msi-access-token"])</value>
</set-header>

但我发现错误消息非常模糊,而且我没有在网上找到任何帮助,所以我不确定我需要做什么来设置此配置。我浏览了有关此主题的多个文档和博客文章,但找不到有关 Azure Active Directory 中要更改的内容的任何信息。如果您能指出正确的方向,我将不胜感激。

我通过从 APIM 入站策略中删除客户端 ID 解决了这个问题。