Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when try to add policy by using #2

Closed
yongding422 opened this issue Jul 27, 2021 · 7 comments
Closed

Exception when try to add policy by using #2

yongding422 opened this issue Jul 27, 2021 · 7 comments

Comments

@yongding422
Copy link

When trying to add the authorization policy, getting following exception:
image

I am using Azure Function V3, and here are packages my project referencing.
image

Could you please help to take a look? Is there any package I am missing?

Thank you.

@artmasa
Copy link
Contributor

artmasa commented Jul 30, 2021

Thanks for reporting @yongding422. Let me look into this.

@artmasa
Copy link
Contributor

artmasa commented Jul 30, 2021

@yongding422, a new version of the package is available 3.0.12-preview-210730-1

For details on the problem take a look at this: https://docs.microsoft.com/en-us/dotnet/core/compatibility/aspnetcore#authorization-addauthorization-overload-moved-to-different-assembly

A direct dependency to Microsoft.AspNetCore.Authorization >=3.0.0 has been added to package

@yongding422
Copy link
Author

Thanks for your response. I tested the new version by creating a new function app, however this time I got following exception:
image

@artmasa
Copy link
Contributor

artmasa commented Aug 4, 2021

@yongding422, the problem is that the package targets .NET Standard 2.1 because I didn't want to target a specific runtime. 3.0, 3.1 etc..., so I'm referencing Microsoft.AspNetCore.Authentication.JwtBearer 2.2.0
If for example you are using netcoreapp3.1 in your project as the target framework and adding JWT auth for authentication, add the specific version of Microsoft.AspNetCore.Authentication.JwtBearer for your specific project (3.1.1 for example)
Based on my testing, once I add the more specific version of the package to my functions project, the runtime is able to target the right method for Authorization.

All this is happening because of all the breaking changes explained in the article I linked in the comments above.

Please let me know if this solves the problem.

@yongding422
Copy link
Author

Hi Arturo,
Thank you for your response. It worked after I upgrade the package Microsoft.AspNetCore.Authentication.JwtBearer. However after I deployed the function app to Azure, from the Azure portal, it cannot recognize the function app runtime. I am able to call the function by using the function url, however from the Azure portal it shows that function runtime is unreachable, and I cannot find any endpoints when trying to import endpoints to APIM. Have you ran into the same issue?

Thanks

@yongding422
Copy link
Author

Hi Arturo,

I did some search online, and found out this is an knowing issue for Function App, there is a workaround for it, but looks like this workaround solution only works for .net core 3.1. Here is the url -- AzureAD/microsoft-identity-web#916

Thanks,

@artmasa
Copy link
Contributor

artmasa commented Nov 18, 2021

@yongding422, thanks for the update. I will close this issue

@artmasa artmasa closed this as completed Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants