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

Поділитися
Вставка
  • Опубліковано 14 кві 2022
  • 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.talkpython.fm/course...
    Getting started with Python and Azure Functions
    docs.microsoft.com/en-us/azur...
    Visual Studio Code with Python
    code.visualstudio.com/docs/la...
    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
  • Наука та технологія

КОМЕНТАРІ • 29

  • @lacroixboi
    @lacroixboi Рік тому +1

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

    • @ChristosMatskas
      @ChristosMatskas  Рік тому +1

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

  • @rabim8819
    @rabim8819 Рік тому +1

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

  • @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*

  • @ashisharya65
    @ashisharya65 5 місяців тому +2

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

    • @ChristosMatskas
      @ChristosMatskas  5 місяців тому +1

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

  • @amarqueze
    @amarqueze 8 місяців тому +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  8 місяців тому

      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…

  • @CJRomberger
    @CJRomberger 5 місяців тому +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 12 днів тому

      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.

  • @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?

  • @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.

  • @patrickmurray1988
    @patrickmurray1988 8 місяців тому

    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  8 місяців тому

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

  • @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

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

    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  Рік тому

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

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

      @@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  Рік тому

      @@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 Рік тому +1

      @@ChristosMatskas ok thanks for the help

  • @mff5610
    @mff5610 Рік тому +2

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

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

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