Secure Serverless APIs with Python FastAPI, Azure AD and Azure Functions

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ต.ค. 2024
  • Step by step video on how to create serverless APIs using Azure Functions with Python and Fast API. Secure your API with JWT based authentication and authorization with Azure Active Directory to ensure that only authenticated requests can access your API endpoints.
    TWITTER ►► / christosmatskas
    INSTAGRAM ►► / cmatskas
    TIKTOK ►► / christosmatskas
    Secure APIs with FastAPI and the Microsoft Identity Platform
    training.talkp...
    Getting started with Python and Azure Functions
    docs.microsoft...
    Visual Studio Code with Python
    code.visualstu...
    00:00:10 Dependencies
    00:01:05 Create a local Python Azure Function project
    00:04:26 Configure Azure Active Directory
    07:12:00 Use ThunderClient to get an access token
    00:07:54 Validate the token in jwt.ms
    00:08:23 Implement Fast API in Azure Functions
    00:10:00 Add API Authorization
    00:12:50 Testing authentication end-to-end
    #python #serverless #fastapi #jwt #authentication #azuread

ความคิดเห็น • 32

  • @lacroixboi
    @lacroixboi 2 ปีที่แล้ว +1

    you and the 425 crew put out some really awesome videos. Much appreciated!

    • @ChristosMatskas
      @ChristosMatskas  2 ปีที่แล้ว +1

      Thanks Brett. I will be getting back to creating content once we settle into the new house and my office is set up

  • @MuhammadHamid-r6o
    @MuhammadHamid-r6o 2 หลายเดือนก่อน

    you are doing great work please continue with that amazing content

  • @rabim8819
    @rabim8819 2 ปีที่แล้ว +1

    Nice one!, I like the music and the vibe.

  • @ashisharya65
    @ashisharya65 9 หลายเดือนก่อน +2

    could you please reveal the VS code theme you are using in this video?

    • @ChristosMatskas
      @ChristosMatskas  9 หลายเดือนก่อน +1

      Absolutely! It’s the Bearded Theme for VS Code marketplace.visualstudio.com/items?itemName=BeardedBear.beardedtheme

  • @CJRomberger
    @CJRomberger 8 หลายเดือนก่อน +1

    When I hit Generate Token, absolutely nothing is happening. Haha. Dead in the water. No browser window open. Going back to the beginning of the video to see if I messed something up, or maybe something has changed? In any case, this is an awesome video for understanding the pieces of this.

    • @MT-gw4vm
      @MT-gw4vm 3 หลายเดือนก่อน

      If anyone else runs into this problem, it would probably just be the wrong values entered. To my knowledge, thunderclient won't provide any errors, so the only thing you will see is the access token not populating in the box. I switched over to postman (make sure you used the postman callback URL provided), and with the postman console open, I was able to see the specific errors logged.
      My problem was that even though I hit generate token and the web browser showed me the success page, no access token was populated. Postman told me that that an invalid client secret was provided, and I ended up using the secret ID instead of the secret value.

    • @MicrosoftAzureAI
      @MicrosoftAzureAI หลายเดือนก่อน

      were you able to resolve this? i got the same isse

    • @MicrosoftAzureAI
      @MicrosoftAzureAI หลายเดือนก่อน

      ok nvm. it works now.. its a matter of just setting the right parameters

  • @amarqueze
    @amarqueze 11 หลายเดือนก่อน +1

    Great video Christos! I'm wondering if you have the plan to perform the same using Python v2 programming model. I tried to implement by myself but so far I've failed (not able to enable fastapi with microsoft AD in v2)

    • @ChristosMatskas
      @ChristosMatskas  11 หลายเดือนก่อน

      Thanks for the kind comments. Unfortunately I’ve moved away from that space and I’m not actively working on this any more. I would highly recommend that you reach out to the Azure AD team to ask for support with Python 2. I hope this helps…

  • @arashjavanmard5911
    @arashjavanmard5911 ปีที่แล้ว +2

    Great video. Thanks a lot. But I have some problems running the code:
    1. azure func-tool uses system python and not the vend-python. For this, I needed to install fastapi and other stuff using system pip.
    2. In weather.py-file requires_auth-function needs an "f" parameter. Otherwise, it raises type-error.
    I am grateful for any support.

    • @ChristosMatskas
      @ChristosMatskas  ปีที่แล้ว +1

      Please reach out to the Azure Functions team for tool issues. They are very good at responding quick and helping with problems

    • @arashjavanmard5911
      @arashjavanmard5911 ปีที่แล้ว +1

      @@ChristosMatskas thanks a lot for your quick response. What about the "requires_auth"-function parameter?

  • @josesimoes3478
    @josesimoes3478 ปีที่แล้ว

    Nice video, I'm not too familiar with Azures services so it was rather insightful
    I need to give a thumbs up for the *wink wink*

  • @thatsenpaifrommars
    @thatsenpaifrommars 2 ปีที่แล้ว +2

    What VS code theme do you use?

    • @ChristosMatskas
      @ChristosMatskas  2 ปีที่แล้ว +2

      I use the Bearded Theme: marketplace.visualstudio.com/items?itemName=BeardedBear.beardedtheme

    • @thatsenpaifrommars
      @thatsenpaifrommars 2 ปีที่แล้ว

      @@ChristosMatskas Thanks

  • @patrickmurray1988
    @patrickmurray1988 ปีที่แล้ว

    I have followed the instructions exactly and keep getting "Invalid_header: Unable to parse authentication" for the final API call. Any help on this?

    • @ChristosMatskas
      @ChristosMatskas  ปีที่แล้ว

      You may need to inspect the incoming header as things may have changed since this course was released…

  • @victormanuelagudelomedina3228
    @victormanuelagudelomedina3228 2 ปีที่แล้ว

    Do you know why ciuld have this error: ModuleNotFoundError: No module named "routers". I don't kno wwhy this can happen because I created the directory as you did and the weatehr.py as you wrote it

    • @tornoutlaw
      @tornoutlaw 2 ปีที่แล้ว

      have you initialized your "routers" directory as a module? If not, try adding an (empty) __init__.py into it.

  • @yashvardhan7880
    @yashvardhan7880 2 ปีที่แล้ว

    Microsoft.AspNetCore.Routing: An error occurred while creating the route with name 'function' and template 'api//{*route}'. Microsoft.AspNetCore.Routing: The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value. (Parameter 'routeTemplate'). Microsoft.AspNetCore.Routing: The route template separator character '/' cannot appear consecutively. It must be separated by either a parameter or a literal value.
    I am getting this error what should be done??

    • @ChristosMatskas
      @ChristosMatskas  2 ปีที่แล้ว

      Did you follow my steps exactly or did you change the code in the Azure Function?

    • @yashvardhan7880
      @yashvardhan7880 2 ปีที่แล้ว

      @@ChristosMatskas well i modified it for me
      I just wanted to know if there is something that can be done to fix it

    • @ChristosMatskas
      @ChristosMatskas  2 ปีที่แล้ว

      @@yashvardhan7880 you can reach out to support or search on stack overflow. I’ve seen this error before but I can’t remember how I went about fixing it. You can hit the Azure Functions team on Twitter @azurefunctions - they’re usually very good at getting back to you

    • @yashvardhan7880
      @yashvardhan7880 2 ปีที่แล้ว +1

      @@ChristosMatskas ok thanks for the help

  • @mff5610
    @mff5610 2 ปีที่แล้ว +2

    Definitely not for beginners, you have missed multiple steps and basic introductions.

    • @ChristosMatskas
      @ChristosMatskas  2 ปีที่แล้ว

      There is a whole course that goes through all the basics you need. This video assumes that you have a good understanding of authentication