| page_type | description | languages | products | |||
|---|---|---|---|---|---|---|
| sample | A minimal sample app that can be used to demonstrate deploying FastAPI apps to Azure App Service. | 
 | 
 | 
This is the sample FastAPI application for the Azure Quickstart Deploy a Python (Django, Flask or FastAPI) web app to Azure App Service. For instructions on how to create the Azure resources and deploy the application to Azure, refer to the Quickstart article.
Sample applications are available for the other frameworks here:
- Django https://github.com/Azure-Samples/msdocs-python-django-webapp-quickstart
- Flask https://github.com/Azure-Samples/msdocs-python-flask-webapp-quickstart
If you need an Azure account, you can create one for free.
To try the application on your local machine:
pip install -r requirements.txt
uvicorn main:app --reload
Build the image locally
docker build --tag fastapi-demoRun the image locally in a Docker container.
docker run --detach --publish 3100:3100 fastapi-demoOpen the http://localhost:3100 URL in your browser to see the web app running locally.
Deploy web app to Azure
To deploy the Docker image to Azure Container Apps, use the az containerapp up command. (The following commands are shown for the Bash shell. Change the continuation character () as appropriate for other shells.)
Flask
FastAPI
Azure CLI
az containerapp up \
  --resource-group web-fastapi-aca-rg --name web-aca-app \ 
  --ingress external --target-port 3100 --source .When deployment completes, you have a resource group with the following resources inside of it:
An Azure Container Registry
A Container Apps Environment
A Container App running the web app image
A Log Analytics workspace
To learn more about FastAPI, see FastAPI.