name: audify description: "A minimal sample app that uses Auth0, FastApi and Azure App Services" languages:
- python
- javascript
- html
- css
- azurecli products:
- azure
- azure-app-service
- auth0
This is the sample FastAPI application for deploying FastAPI apps to Azure App Service with Auth0 authentication. The application demonstrates a minimal setup required to get a FastAPI web app up and running and integrated with Azure services.
To create an effective project structure for your FastAPI project "AudifyApp" that can be displayed in the README file, I recommend the following structure. This structure is based on best practices for organizing FastAPI projects and can help improve the readability, maintainability, and scalability of your project. Note that this structure should be adapted to your specific requirements:
AudifyApp/
│
├── app/ # Main application folder
│ ├── api/ # Endpoints and API-specific logic
│ │ ├── dependencies/ # Dependencies for the API routes
│ │ ├── routers/ # Files for individual routes
│ │ └── responses.py # Custom response models
│ │
│ ├── core/ # Core configurations and settings
│ │ ├── config.py # Configuration file for the project
│ │ └── security.py # Security settings, e.g., for authentication
│ │
│ ├── models/ # Database models
│ │ └── models.py # SQLAlchemy models
│ │
│ ├── schemas/ # Pydantic schemas for request and response
│ │ └── schemas.py # Definition of schemas
│ │
│ ├── services/ # Business logic and services
│ │ └── service.py # Service classes and functions
│ │
│ └── main.py # FastAPI application instance and router imports
│
├── tests/ # Test folder
│ └── test_api.py # Test cases for the API
│
├── .env # Environment variables and configurations
├── .gitignore # Gitignore file
├── Dockerfile # Dockerfile for containerization
├── requirements.txt # Project dependencies
└── README.md # README file with project overview and instructions
- app/api: Contains your route definitions and API-specific logic. Routers organize endpoints into logical groups.
- app/core: Includes core configuration files like the application configuration and security settings.
- app/models: Defines your database models using SQLAlchemy for ORM (Object-Relational Mapping).
- app/schemas: Contains Pydantic models for data validation and serialization of requests and responses.
- app/services: Houses the business logic of your application, separated from the API logic for improved reusability and maintainability.
- tests: Contains your test cases, promoting a test-driven development (TDD) approach.
pip install -r requirements-dev.txt
pre-commit install
uvicorn main:app --reload
Open http://127.0.0.1:8000/ in your browser to access the app locally.
docker build --tag audifywebapp .
docker run --detach --publish 3100:3100 audifywebapp
Open http://localhost:3100 in your browser to see the web app running locally.
az login
az group create --name rg-audifywebapp --location eastus
az acr create --resource-group rg-audifywebapp --name audifywebapp --sku Basic --admin-enabled true
az acr build --resource-group rg-audifywebapp --registry audifywebapp --image audifywebapp:latest .
az appservice plan create --name webplan --resource-group rg-audifywebapp --sku B1 --is-linux
az webapp create --resource-group rg-audifywebapp --plan webplan --name audifywebapp --deployment-container-image-name audifywebapp.azurecr.io/audifywebapp:latest
After making code changes, redeploy to App Service with the following commands:
az acr build --resource-group rg-audifywebapp --registry audifywebapp --image audifywebapp:latest .
az webapp update --name audifywebapp --resource-group rg-audifywebapp --docker-registry-server-password <$ACR_PASSWORD> --deployment-container-image-name audifywebapp.azurecr.io/audifywebapp:latest
We welcome contributions! Please read our CONTRIBUTING.md for details on how to submit contributions to this project.
If you encounter any issues or have feature suggestions, please file them in the ISSUE of this repository.
See the CHANGELOG.md for details on changes and updates made to the project.
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 learn more about FastAPI, visit FastAPI documentation.