How to Launch a FastAPI Service in Azure Containers in Less Than 10 Minutes!

Поділитися
Вставка
  • Опубліковано 6 лип 2024
  • In this video, we're going to show you how to have your FastAPI service up and running on Microsoft Azure Container Instances in UNDER 10 minutes!
    If you're looking to get started with building your own cloud-based applications, then you'll want to check out this video. We'll teach you how to create a containerized Python FastAPI application, and then deploy the service to Azure Container Registry, and then finally fire it up into life through Azure Container Instances.
    This quick and easy tutorial will have you up and running with FastAPI in no time!
    -------------------------------------
    What's on the agenda for today?
    00:00 Introduction
    00:14 Looking at the code
    01:24 Running the service
    02:29 Putting the app in a container
    04:53 Getting the container onto Azure
    08:17 Thanks for watching!
    -------------------------------------
    Check out the FastAPI docs for loads of extra things you can do:
    fastapi.tiangolo.com/
    For the code used in this video:
    github.com/rowanlea/FastAPIEx...
    -------------------------------------
    If you need any help with Azure feel free to contact me through UA-cam or any of the links below.
    My Links:
    ► Website: rowanlea.co.uk/
    ► GitHub: github.com/rowanlea
    ► LinkedIn: / rowan-lea
    ► Twitter: / rowanlea1
    You can also message me personally at: mail@rowanlea.co.uk
    -------------------------------------
    Join in and don't miss out by subscribing and returning weekly for the freshest and most exciting videos around!
    #azure #container #python #fastapi
  • Наука та технологія

КОМЕНТАРІ • 64

  • @rowan-lea
    @rowan-lea  Рік тому +3

    Instead of re-building your docker image you can also just change the tag (thanks for the tip Sam):
    `docker image tag `

  • @reddymvanirudh167
    @reddymvanirudh167 20 днів тому

    dude
    u just saved my life........
    thanks and respect from INDIA...

  • @wassimsaioudi116
    @wassimsaioudi116 Рік тому +8

    Finally I found the easiest tutorial ever ! Thank you so much !!

    • @rowan-lea
      @rowan-lea  Рік тому

      Glad you found it useful! My main goal is to make my tutorials as quick and easy to understand as possible. Let me know if there's anything similar on Azure you think could do with a similar explanation to it!

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

    Instant sub. Extremely fast, thorough and easy explanation.

    • @rowan-lea
      @rowan-lea  5 місяців тому

      Really appreciate it, thank you!!

  • @scrtempire8122
    @scrtempire8122 7 місяців тому +1

    Very well made. I was struggling for a few hours until I came across your video. Concise and straight to the point!

    • @rowan-lea
      @rowan-lea  7 місяців тому

      Thanks so much! Glad it helped you :)

  • @charlessandholm757
    @charlessandholm757 Місяць тому

    Fast and to the point! Many thanks.

  • @ricardorolin7791
    @ricardorolin7791 4 місяці тому +1

    Damn, i not use to comment videos, but you deserve it. I send you a firm, solid and dry, 3 seconds hand shake sir.

    • @rowan-lea
      @rowan-lea  4 місяці тому

      Thank you so much! Glad you liked it 😊

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

    Great tutorial. Thanks!

  • @0suresh
    @0suresh 8 місяців тому +1

    Thank so much please upload more more ...

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

    Thank you! This helped a lot.

    • @rowan-lea
      @rowan-lea  Рік тому

      Glad you enjoyed it! Let me know if there's anything similar you'd like to see :) My most recent video shows you how to remote debug the app in this video!

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

    Thanks Rowan, just what I was looking for!

    • @rowan-lea
      @rowan-lea  4 місяці тому

      Thanks! Glad it helped :)

  • @rounaksinghbuttar9083
    @rounaksinghbuttar9083 4 місяці тому +1

    Thank you so much 🙏

    • @rowan-lea
      @rowan-lea  4 місяці тому

      Glad you liked it!

  • @claytonvanderhaar3772
    @claytonvanderhaar3772 28 днів тому

    Hi yes great and very easy to understand, although wanted to check if it is possible to change the IP to a more readable URL

  • @user-yr4jf2vs2s
    @user-yr4jf2vs2s 11 місяців тому +1

    Awesome tutorial!

    • @rowan-lea
      @rowan-lea  11 місяців тому

      Thanks very much, glad you enjoyed it!!

  • @sachin01663
    @sachin01663 9 днів тому

    Thank you. Very useful. Does the IP change if we re-build the docker?

  • @tessa10001
    @tessa10001 9 місяців тому +1

    Great tutorial, very helpful! Everything still works

    • @tessa10001
      @tessa10001 9 місяців тому

      Edit: how do you make it https instead of http though

    • @rowan-lea
      @rowan-lea  9 місяців тому

      @@tessa10001 Glad you enjoyed it! If you change the port in the code to 443 that should be enough. When you set up a container it should have port 443 used for https bound by default. If that doesn't work give me a shout!

    • @tessa10001
      @tessa10001 9 місяців тому

      @@rowan-lea oh that is really helpful. I wont test this out though because i already set up a web app with this container instead

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

    Great video! very detailed explainations! I have a quick question. The container published to Azure container registry will be public assessible as well? thx

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

    wonderfully stripped down to essentials -- the MS documentation for the same need (deploy a FastAPI Python Server using docker in Azure) adds a lot of unnecessary steps if you just want a pure API server as you have shown, thanks!

    • @rowan-lea
      @rowan-lea  5 місяців тому

      Thank so much, glad you liked it!!

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

    Thanks mate. Super useful. Any chance you can do a vid on debugging the code in the container on Azure?

    • @rowan-lea
      @rowan-lea  Рік тому

      Hey Alan, glad it helped! That's an awesome idea for a video, I'm going to add that to my list (very near the top, because that sounds like something very helpful to show).

    • @rowan-lea
      @rowan-lea  Рік тому

      You inspired me! ua-cam.com/video/82DEbrwqPvE/v-deo.html

  • @luchaojin4030
    @luchaojin4030 6 місяців тому +1

    I your video! To the point and helpful! I followed your video deployed a fastapi to Azure. Everything is fine when I do docker test locally. But the container instance I created cannot be started (kept being killed and start). If you have any insights?

    • @rowan-lea
      @rowan-lea  6 місяців тому

      Hey, glad you liked it! Do you mean it starts up initially and then ends straight away? I'm assuming this is consistent? Or it only starts some of the time?

  • @fb2io383
    @fb2io383 3 місяці тому

    Thanks for the explanation, it's very precise, sort and easy. The problem for me is simply that is not running, the container is stopped by Azure for no reason apparently every time that i try to run it. In the overview of the container I got a warning message: "One or more of the containers in 'fastapitest' are in a 'Waiting' state and may not be running'. I've tried with my own fastapi container and also with your exact same code from github. I wonder if Microsoft has change something. Thanks a lot!

    • @samirwalji7613
      @samirwalji7613 3 місяці тому

      Having the same issue - did you ever figure this out?

  • @emrahe468
    @emrahe468 5 місяців тому

    If you're looking to leverage GPU capabilities within your containerized applications on Azure, it's important to be aware that accessing GPU resources for Azure Container Instances requires applying for a quota. However, there's a possibility that your request might not be approved due to current limitations and high demand for GPU resources. (my application wasn't approved)
    As a result, an alternative and more reliable approach would be to provision a Virtual Machine (VM) equipped with a GPU. You can then deploy your Docker containers on this VM. Additionally, it would be greatly beneficial for users like myself if you could provide a detailed tutorial on this process.

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

    Awesome tutorial everything worked out but for the last part, after creating container instance i am trying to access with container’a IP but getting a gateway timeout error. Any idea?

    • @rowan-lea
      @rowan-lea  Рік тому +1

      Hey Suhas, sometimes it happens if you try to access the resources too quickly after creating them, it can take a couple of minutes for container resources to actually be created in the background (even after it says they're ready).
      But also, are you using a similar "bare bones" set up like I am, or are you utilising any additional resources (like load balancers). Also, are all of your resources deployed to the same location? It shouldn't add enough time to cause a timeout error, but you never know!

  • @RohitKumar-fr4cm
    @RohitKumar-fr4cm 6 місяців тому +1

    Thanks I was able to get the public ip address but the problem is I need a https for integrating it with with frontend how can I do so ?

    • @rowan-lea
      @rowan-lea  6 місяців тому

      In the dockerfile you should be able to change the 80 on the last line to 443, this should do it for you, Azure Containers will have the port open by default for you.

  • @sreedharsharma9082
    @sreedharsharma9082 2 місяці тому

    what if Docker desktop is not available? wsl2 is not being installed on my machine to run docker. can someone help me please?

  • @fannyguthmann7566
    @fannyguthmann7566 5 місяців тому

    Hey, thank you so much for this amazing tutorial. I did everything you did step by step. I created the container instance.
    I'm getting an error on Azure, "One or more of the containers in 'aci-fast-api' are in a 'Waiting' state and may not be running. Click here to view container statuses."
    I waited, restarted but still getting the same error.
    Should I have done something in Azure before doing your tutorial. It's my first time using Azure and I'm really confuse on how to fix this error

    • @rowan-lea
      @rowan-lea  5 місяців тому +1

      Hey! Glad you liked it :) Sometimes you get weird errors like that for all kinds of reasons. From my experience usually deleting the resource and creating it again can help solve the problem.

    • @fannyguthmann7566
      @fannyguthmann7566 5 місяців тому

      @@rowan-lea Thank you very much, I'm going to try again :)

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

    step on Azure that free or not sir ?
    and necessary to use with Dockerfile ?

    • @rowan-lea
      @rowan-lea  8 місяців тому

      You don't need to do the Azure parts, you can run it locally or find another host. As for the dockerfile I'm not entire sure, I don't do much docker development that doesn't use it. Perhaps a docker compose file could work, but I'm not sure if that's a direct replacement or something you need on top of a dockerfile.

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

    What will the pricing for this?
    Container registery and container instance?
    Is it too costly compare to virtual machines?

    • @rowan-lea
      @rowan-lea  Рік тому

      From my experience, and stuff I've been playing with recently, in GBP the cost of the services combined, for a basic app like this, would be about £35-£40 a month, provided it was running.
      From my experience containers would typically be cheaper to run than VMs (that's kind of the point, small and more lightweight), however the Azure pricing pages don't really seem to support that theory strongly:
      azure.microsoft.com/en-gb/pricing/details/virtual-machines/windows/
      azure.microsoft.com/en-gb/pricing/details/container-instances/
      I recently put out a video about ways you can check your pricing, so you might be able to figure it out from here:
      ua-cam.com/video/gy0n_jt-Ato/v-deo.html

    • @rowan-lea
      @rowan-lea  Рік тому

      To add to this, I don't really like interacting Linux as an OS, but I would always choose it for my container OS because you don't have to pay the additional licensing fee that you do with Windows, and using a container means I don't have to touch it as an OS.

  • @piotrek8809
    @piotrek8809 10 місяців тому +1

    How to connect it with database?

    • @rowan-lea
      @rowan-lea  10 місяців тому

      So you probably want to make some kind of database service you can call when an endpoint gets hit. Really you could use any kind of database depending on your needs, because there's so many different types it would probably make sense to look for a Python video for your specific database implementation.

    • @andreww2528
      @andreww2528 4 місяці тому +1

      @@rowan-lea I'm also interested in this, would you be open to ever making an additional video that uses an example database?

    • @rowan-lea
      @rowan-lea  4 місяці тому +1

      @@andreww2528 actually this came up in conversation literally today, maybe I will!

  • @johnwright1152
    @johnwright1152 3 місяці тому

    Why did you go with a container vs Azure function? Containers look to be more expensive. What am I missing?

    • @rowan-lea
      @rowan-lea  3 місяці тому

      Hey John, both have completely different use cases really. Functions are for short lived processes, and are very specific in how they are programmed. Containers are typically longer lived, can have much more compute power, and are less tied to any particular technology (i.e. you could make an app in any language and easily move it to something like AWS if you wanted to).
      This video isn't to determine which is best, that depends entirely on your use case :)

    • @rowan-lea
      @rowan-lea  3 місяці тому

      To add to that, typically you're right in terms of cost, running something native to a platform is nearly always cheaper from my experience, but that's not really a good reason to choose one technology over the other, unless you can completely ignore any other factors.

  • @DavidManouchehri
    @DavidManouchehri 8 місяців тому +1

    How can you add HTTP authentication to a Container App? I know we could add it at the application layer, but then we'd get billed for even unauthorized attempts..

    • @rowan-lea
      @rowan-lea  8 місяців тому

      This should solve your problem as it uses middleware before it gets to your app: learn.microsoft.com/en-us/azure/container-apps/authentication

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

      @@rowan-lea From the diagram, won't I still be billed for any requests to the authentication middleware container? The box around both containers makes it seem like they're both running in my account.

    • @rowan-lea
      @rowan-lea  7 місяців тому

      @@DavidManouchehri I'm not sure if they do charge for that. Ultimately you're going to need some kind of control in the way to block the request, it could even be a firewall. Most of these things I would imagine will be a 1 off monthly cost rather than something you pay for per request. There may be another way but it's not something I have much information about sorry.

    • @DavidManouchehri
      @DavidManouchehri 7 місяців тому

      @@rowan-lea I did find out that APIM is Azure's solution, but it costs hundreds per year. 😅
      We ended up using Google Cloud Run instead, since authenticating service-to-service requests is free. (AWS Lambdas can also authenticate service-to-service requests, but it's a bit of a pain to deploy Lambda containers compared to Clod Run.)

  • @user-cn9sb4qi8t
    @user-cn9sb4qi8t 7 місяців тому +1

    I really hate the way you chose to talk , but thanks for the video