Azure Function with AD auth results in 401 Unauthorized when using Bearer tokens

前端 未结 7 563
春和景丽
春和景丽 2020-12-29 07:47

I have a very simple Azure function in C# for which I\'ve setup Azure AD Auth. I\'ve just used the Express settings to create an App registration in the Function configurati

7条回答
  •  执笔经年
    2020-12-29 08:11

    When setting up your Active Directory authentication on your Function App, set management mode to advanced and fill in the Client ID and Issuer URL as required (and the client secret if necessary).

    Importantly, under the Allowed Token Audiences, enter the Application ID URI. This can be found in your registered App Registration (in your AD) under the Expose an API option.

    This is what I was missing to get authentication working on my Function App. Before I added that token audience, I would always get a 401 with a valid access token.

    This Azure active directory - Allow token audiences helped me get my answer but it took me a while to realise what it was referring to. Remember, it's the Application ID URI that can be found within your App Registration.

    I hope it helps!

提交回复
热议问题