Це відео не доступне.
Перепрошуємо.

Authenticate Azure Function with Azure Web App Using Managed Service Identity

Поділитися
Вставка
  • Опубліковано 18 сер 2024
  • Azure Functions are getting popular, and I start seeing them more at clients. One typical scenario I come across is to authenticate an Azure Function with an Azure Web API. Every time something like this comes up, it means more Azure AD applications, which in turn means more secrets/certificates that need to be managed. But with Managed Service Identity (MSI) feature on Azure, a lot of these secrets and authentication bits can be taken off from our shoulders and left to the platform to manage for us.
    Blog Post: www.rahulpnath...
    Managed Service Identity: docs.microsoft...

КОМЕНТАРІ • 67

  • @alitswq
    @alitswq 3 роки тому +1

    Rahul, The way you show the differences is fantastic. Good job!

    • @RahulNath
      @RahulNath  3 роки тому

      Thank you, happy to hear that and glad you like it! 😀

  • @soucianceeqdamrashti8175
    @soucianceeqdamrashti8175 4 роки тому +6

    Very well explained and good code demo! Keep it up!

    • @RahulNath
      @RahulNath  4 роки тому +1

      Souciance Eqdam Rashti Thank you - glad you liked it😀

  • @ChandanKumar-es7bz
    @ChandanKumar-es7bz 4 роки тому +2

    Thanks man after a long wait i get this video

    • @RahulNath
      @RahulNath  4 роки тому +1

      Thanks for the comment - glad it helps!

    • @ChandanKumar-es7bz
      @ChandanKumar-es7bz 4 роки тому

      @@RahulNath do you have the sample code

    • @RahulNath
      @RahulNath  4 роки тому

      @@ChandanKumar-es7bz Have you checked the associated blog post? It has the relevant code www.rahulpnath.com/blog/how-to-authenticate-azure-function-with-azure-web-app-using-managed-service-identity/
      Let know if that helps

  • @AgeOfFails
    @AgeOfFails 4 роки тому +2

    Seems that I've found a hidden gem! Thanks for the explenation, was very clear and to the point!

    • @RahulNath
      @RahulNath  4 роки тому

      Awesome - glad you liked it!

  • @adamtibi559
    @adamtibi559 3 роки тому +2

    This is a well prepared short video. Thank you.

  • @sbmqureshi77
    @sbmqureshi77 21 день тому

    Rahul your video is very helpful

    • @RahulNath
      @RahulNath  21 день тому

      Very happy to hear that! Hope you are liking the other videos.

  • @libancool
    @libancool 4 роки тому +2

    Thanks, needed this.

  • @xichle
    @xichle 4 роки тому +3

    Thanks! very helpful!

    • @RahulNath
      @RahulNath  4 роки тому

      Thank you for the comment and glad you liked it!

  • @webdeveloperninja9220
    @webdeveloperninja9220 4 роки тому +3

    Thanks man

  • @ashishmishra672
    @ashishmishra672 4 роки тому

    Amazing job explaining Rahul :)

  • @gayanrathnayaka1010
    @gayanrathnayaka1010 2 роки тому +2

    I get the following Error any Idea? Parameters: Connection String: [No connection string specified], Resource: 0a200f72-48d3-4a8d-b7ec-b43b6b879984, Authority: . Exception Message: Tried the following 3 methods to get an access token, but none of them worked. This is only a part of the exception

    • @RahulNath
      @RahulNath  2 роки тому +1

      Looks like it is not able to make a successful connection using Managed Identity. Can you check this post and associated video for more details on Managed Identity and setting it up www.rahulpnath.com/blog/defaultazurecredential-from-azure-sdk/
      Let me know if you have additional questions.

    • @ravitejamnm
      @ravitejamnm 2 роки тому

      I got same error. How did you get it resolved?

  • @sharmarahul17
    @sharmarahul17 Рік тому

    excellent video

    • @RahulNath
      @RahulNath  11 місяців тому

      Glad you liked it!

  • @abdulwestwood625
    @abdulwestwood625 3 роки тому +1

    Excellent video

  • @bencarp
    @bencarp 4 місяці тому

    Regarding the auth level settings for the function. I notice you have it set to function. When using managed identity, does it matter which level is used? Also, do we need to utilize the authentication blade, or does the Azure infra take care of that for us?

  • @techelite1920
    @techelite1920 4 роки тому +1

    Well explained !!!

  • @vinothrajendran858
    @vinothrajendran858 2 роки тому +1

    Thanks for this video Rahul. Do you have video for that web api? I want to know how it is validating this token and how it was registered in AAD?

    • @RahulNath
      @RahulNath  2 роки тому

      Thank you Vinoth. Is this what you are looking for ?
      www.rahulpnath.com/blog/defaultazurecredential-from-azure-sdk/
      www.rahulpnath.com/blog/azure-managed-service-identity-and-local-development/
      If not , could you please clarify your question.

    • @vinothrajendran858
      @vinothrajendran858 2 роки тому

      @@RahulNath Thanks Rahul for your reply. I will come back after working it out. Thanks for sharing this link

  • @piyalibasak6886
    @piyalibasak6886 Рік тому

    I have some confusion on it.Please cleare it.Generally I know herein this case case i need two app registration.one for web api another for azure function.bt here we have used one app registration,the one we have configured in web api..same one we have used in function app to call the web api..can you please explain why?.If I create another app registration for function app.and that function app client id if I use to call the web api is that correct?

  • @Wanted_VXRAIL
    @Wanted_VXRAIL 2 роки тому +1

    Im having big troubles trying to get a valid accesstoken using a user assigned identity in azure functions to call my api which is an appservice. I get a token out of it but I cant access the api, it says neither scope or claim was found in token. Any idea?

    • @RahulNath
      @RahulNath  2 роки тому

      Did you try inspecting the token in jwt.io to see what it contains? Can you provide more details on your setup? I'm assuming you don't have any Azure function in the mix (just checking since the comment is under this video 😀)

    • @arunampk
      @arunampk 2 роки тому +1

      @@RahulNath Thanks for the video, well explained! However, I have the exact same problem as Fatgamer. Is there a way that i can email you the problem? The JWT doesn't seem to have the scope or claim so obviously the API is rejecting it.

    • @RahulNath
      @RahulNath  2 роки тому

      @@arunampk Hard to tell what the problem is - Did you try inspecting the token using jwt.io? Sometimes it might take a few minutes for the claims to reflect.

    • @arunampk
      @arunampk 2 роки тому +1

      @@RahulNath The bit which is missing in this video is the AD set up i.e. how to do app registrations etc. I feel i would have been amazing i you shown end to end. Any thoughts Rahul?

    • @RahulNath
      @RahulNath  2 роки тому

      @@arunampk Did you get a chance to check this blog post? www.rahulpnath.com/blog/how-to-authenticate-azure-function-with-azure-web-app-using-managed-service-identity/
      It explains the AD Setup as well, which is covered as part of a separate video

  • @TheShrutika
    @TheShrutika 2 роки тому +1

    Hi Rahul, I am facing a prb in azure functions .. i have installed vs 2019 selecting the azure tools from the installer . I have dot net framework sdk from4.6.1 till 4.8 installed as well. I am able to successfully create, run and debug locally azure functions created using dot net core . I’m the solution explorer I can see the azure function icon and it runs perfectly fine . But with dot net framework it doesn’t. It creates some sort of class project which I can’t run locally .. any idea what I am missing here ?? Please lemme know it will be great help

    • @RahulNath
      @RahulNath  2 роки тому +1

      Hey Shrutika , Any reason you are trying to run it with .NET framework instead of core? This link will help you with the .NET versions and the support for Azure Functions
      docs.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=in-process%2Cv4&pivots=programming-language-csharp&WT.mc_id=AZ-MVP-5003875
      Think you will need to be on 1.x function runtime to be able to run it. Let me know if that helps or if you have additional questions.

    • @TheShrutika
      @TheShrutika 2 роки тому

      @@RahulNath lemme try this and get back to you

    • @TheShrutika
      @TheShrutika 2 роки тому +1

      @@RahulNath I checked the csproj file its v1 net6.0
      v4 . Funny part is the same setup runs on my collegues laptop which i set up. not sure whats issue in my system

    • @RahulNath
      @RahulNath  2 роки тому

      @@TheShrutika What issue do you see in yours?

    • @TheShrutika
      @TheShrutika 2 роки тому +1

      Can I attach screenshots somewhere !? So it can be easily understood

  • @IndrajithReddyMandapati
    @IndrajithReddyMandapati 3 роки тому

    Azure Service Token Provider is working only after deploying into Azure. Getting error while running in local machine. Can you please tell how to get token in local development and in postman?

    • @RahulNath
      @RahulNath  3 роки тому

      To get ManagedIdentity working on a local machine there are a couple of ways. I have written about it here in this blog post-www.rahulpnath.com/blog/azure_managed_service_identity_and_local_development/
      DefaultAzureCredential is the new library to be used when getting ManagedIdentity token. You can read more about it here www.rahulpnath.com/blog/defaultazurecredential_from_azure_sdk/
      I also have videos on the same, which are linked in the blog posts. Let me know if that helps and if you have any further questions.

  • @santhoshcholleti2249
    @santhoshcholleti2249 Рік тому

    How to debug it locally?

    • @RahulNath
      @RahulNath  Рік тому

      Which part are you specifically looking for to debug locally? I did write about Managed Identity local development here www.rahulpnath.com/blog/azure-managed-service-identity-and-local-development/

  • @vivek3amity
    @vivek3amity 3 роки тому

    Nice demo. You have done changes in Functionapp by enabling System assigned identity and Getting the token for a client id. How is the api's secured? Anybody can enable identity and generate token using client id and he/she can invoke api?

    • @RahulNath
      @RahulNath  3 роки тому +1

      Thanks Vivek. The API is secured using Managed Identities. Azure is managing the Id/Secret for us in this case. You can read more about it here docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview?WT.mc_id=AZ-MVP-5003875. Anyone who has access to your azure subscription and has the appropraite access to your resources only will be able to do this. Let know if that answers your question and need further info

    • @vasuroy6214
      @vasuroy6214 3 роки тому

      @@RahulNath I have some follow up questions :-
      1. How to provide access to functions apps and other backend and web API's, present in different RGs ?
      2. How to provide access to functions apps and other backend and web API's, present in different subscriptions ?
      3. Suppose if I have 2 functions Apps(F1 and F2) , for both I have configured System MI as enabled, I want only F1 to access my API and not F2 , how can I control this ?

    • @RahulNath
      @RahulNath  3 роки тому +1

      @@vasuroy6214 Hey Vasu, Within the same tenant you should be able to use Managed Identities. If you are looking at cross tenant then you will not be able to use Managed Identity but will have to use app tokens/Identity Server depending on your setup.

  • @sawarkarashish
    @sawarkarashish 3 роки тому

    Explained very well and I followed all steps for MSI but getting the error of unauthorized. Can you plz guide me where can be issue?

    • @RahulNath
      @RahulNath  3 роки тому

      Glad you liked it. Sometimes it takes around 10-15 minutes to reflect. Are you still facing the same error? You can console log the auth token and inspect it in jwt.io/ to check if everything is set up correctly. In case you didn't see it, there is an associated blog post here too www.rahulpnath.com/blog/how-to-authenticate-azure-function-with-azure-web-app-using-managed-service-identity/
      Can you double check all your steps and let know if you are still facing the issue?

    • @sawarkarashish
      @sawarkarashish 3 роки тому

      @@RahulNath Thanks for replying. I am getting access token using MSI but while calling api from function app, I am getting unauthorized and not returning any value from api.

    • @sawarkarashish
      @sawarkarashish 3 роки тому +2

      @@RahulNath It worked for me now.. I forgot to add "app.UseAuthentication();" in web api's startup file. Once again thanks !

    • @RahulNath
      @RahulNath  3 роки тому +1

      @@sawarkarashish Awesome glad you sorted it out!

    • @vinitsingh3395
      @vinitsingh3395 Рік тому

      @@sawarkarashish Thanks, this was the issue and was able to run through the steps smoothly. Thanks for the video @Rahul

  • @Rajeshsingh-ws5th
    @Rajeshsingh-ws5th 3 роки тому

    when it being hard coded it defeated the purpose of security.

    • @RahulNath
      @RahulNath  3 роки тому

      Sorry Rajesh. didn’t understand. what’s hard coded ?

    • @Rajeshsingh-ws5th
      @Rajeshsingh-ws5th 3 роки тому

      @@RahulNath when see it @3.13 (video time) client secret has been hard coded over here and on 6.38, after removing, its open to use by anyone.

    • @RahulNath
      @RahulNath  3 роки тому

      @@Rajeshsingh-ws5th Which is the whole premise of the video. Continue watching and I show you how to remove needing any secrets. Please hear at 4:35 . Keen, you hear your thoughts.

    • @RahulNath
      @RahulNath  3 роки тому

      Also please watch the introduction where I set the context on the video 0:27. I first show the normal way of using it (the client and secret will be moved to config file 4:35 and for demo purposes is shown in the code) and then refactor to use Managed Identity where you don't need any kind of auth and Azure infra takes care of it for you. Hope that clears your question. Happy to help if you have more questions.