在 Azure 应用服务身份验证与身份验证(经典)中重定向以使用 AAD 登录

时间:2021-06-07 21:38:28

标签: azure azure-active-directory azure-functions azure-web-app-service azure-authentication

我正在尝试建立一个系统,让 Azure DataFactory 可以通过其托管标识调用 Azure 函数。这里的好例子:Authorising Azure Function App Http endpoint from Data Factory

但是,这是对 Azure 函数使用旧的(er)身份验证/授权工具,现在已重命名为身份验证(经典)。通过此设置系统很好,我可以拨打电话并获得响应,但升级到授权会导致此问题中断。似乎缺少的关键是“请求未通过身份验证时采取的操作”选项,我似乎无法使用新的授权工具进行设置,但应将其设置为“使用 Azure AD 登录”

总而言之,我如何使用新的授权工具设置此设置,以便 MSI 可以对该功能进行冷却并使用 AAD 进行身份验证。

经典图片

enter image description here

具有新授权的图像(没有可见的重定向到 AAD 的方式)

enter image description here

总而言之,我如何使用新的授权工具设置此设置,以便 MSI 可以对该功能进行冷却并使用 AAD 进行身份验证。

1 个答案:

答案 0 :(得分:1)

要使其与新的 Authentication 配合使用,请按照以下步骤操作。

1.在门户中编辑 Authentication settings 或在创建应用程序时进行如下设置。

enter image description here

2. 编辑 Identity provider,确保 Issuer URLhttps://sts.windows.net/<tenant-id>没有 /v2.0)并且 Allowed token audiences 包括App ID URI

enter image description here

enter image description here

对于App ID URI,您可以在函数应用的AD App中查看-> Expose an API,如果您之前使用旧的Authentication,可能是您的函数应用URL ,这很重要,只需确保 Allowed token audiences 包含它。

enter image description here

3.然后在数据工厂网络活动中,还要确保资源是 App ID URI

enter image description here

然后它会正常工作。

enter image description here

更新:

你可以参考我的配置。

功能应用:

enter image description here

enter image description here

广告应用:

enter image description here

enter image description here

AD 应用清单:

{
    "id": "xxxxxx",
    "acceptMappedClaims": null,
    "accessTokenAcceptedVersion": null,
    "addIns": [],
    "allowPublicClient": null,
    "appId": "xxxxx",
    "appRoles": [],
    "oauth2AllowUrlPathMatching": false,
    "createdDateTime": "2021-06-08T01:51:06Z",
    "disabledByMicrosoftStatus": null,
    "groupMembershipClaims": null,
    "identifierUris": [
        "api://xxxxx"
    ],
    "informationalUrls": {
        "termsOfService": null,
        "support": null,
        "privacy": null,
        "marketing": null
    },
    "keyCredentials": [],
    "knownClientApplications": [],
    "logoUrl": null,
    "logoutUrl": null,
    "name": "joyfuna2",
    "oauth2AllowIdTokenImplicitFlow": true,
    "oauth2AllowImplicitFlow": false,
    "oauth2Permissions": [
        {
            "adminConsentDescription": "Allow the application to access joyfuna2 on behalf of the signed-in user.",
            "adminConsentDisplayName": "Access joyfuna2",
            "id": "1704f162-421d-4733-855f-5d93c0c55689",
            "isEnabled": true,
            "lang": null,
            "origin": "Application",
            "type": "User",
            "userConsentDescription": "Allow the application to access joyfuna2 on your behalf.",
            "userConsentDisplayName": "Access joyfuna2",
            "value": "user_impersonation"
        }
    ],
    "oauth2RequirePostResponse": false,
    "optionalClaims": null,
    "orgRestrictions": [],
    "parentalControlSettings": {
        "countriesBlockedForMinors": [],
        "legalAgeGroupRule": "Allow"
    },
    "passwordCredentials": [
        {
            "customKeyIdentifier": null,
            "endDate": "2031-06-08T01:51:05.573Z",
            "keyId": "c6d4434f-7aaf-4c4c-9428-a38cbf8200bb",
            "startDate": "2021-06-08T01:51:05.573Z",
            "value": null,
            "createdOn": "2021-06-08T01:51:07.3876164Z",
            "hint": "UT_",
            "displayName": "Generated by App Service"
        }
    ],
    "preAuthorizedApplications": [],
    "publisherDomain": "xxxxxx.onmicrosoft.com",
    "replyUrlsWithType": [
        {
            "url": "https://joyfuna2.azurewebsites.net/.auth/login/aad/callback",
            "type": "Web"
        }
    ],
    "requiredResourceAccess": [
        {
            "resourceAppId": "00000003-0000-0000-c000-000000000000",
            "resourceAccess": [
                {
                    "id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
                    "type": "Scope"
                }
            ]
        }
    ],
    "samlMetadataUrl": null,
    "signInUrl": "https://joyfuna2.azurewebsites.net",
    "signInAudience": "AzureADMyOrg",
    "tags": [],
    "tokenEncryptionKeyId": null
}

数据工厂网络活动:

enter image description here