A copy of the slides from my Django on Azure PyCon US 2021 workshop is available in this repository.
- Run the following command to initialize the project.
azd init --template https://github.com/tonybaloney/django-on-azure
This command will clone the code to your current folder and prompt you for the following information:
Environment Name
: This will be used as a prefix for the resource group that will be created to hold all Azure resources. This name should be unique within your Azure subscription.
- Run the following command to build a deployable copy of your application, provision the template's infrastructure to Azure and also deploy the application code to those newly provisioned resources.
azd up
This command will prompt you for the following information:
Azure Location
: The Azure location where your resources will be deployed.Azure Subscription
: The Azure Subscription where your resources will be deployed.
NOTE: This may take a while to complete as it executes three commands:
azd package
(builds a deployable copy of your application),azd provision
(provisions Azure resources), andazd deploy
(deploys application code). You will see a progress indicator as it packages, provisions and deploys your application.
Checkout the Azure Dev CLI documentation for more instructions on using the CLI.
- Web Apps
- App Service Plans
- Continuous Deployment with App Service
- Using LocustIO to load test Django
- Django Template Caching
- Scale up an App in Azure
- Add the following
startup.sh
script
gunicorn --workers 8 --threads 4 --timeout 60 --access-logfile '-' --error-logfile '-' --bind=0.0.0.0:8000 -k uvicorn.workers.UvicornWorker --chdir=/home/site/wwwroot your_django_app.asgi
- Make sure you add
uvicorn
to therequirements.txt
file - Pick the right number of workers and threads for the instance size
- To enable this startup command, you need to set the startup command to startup.sh in Settings -> Configuration -> General Settings -> Startup command. After making these changes, the application will restart
- Azure Database for PostgreSQL
- Azure SQL
- Azure Database for MySQL
- Azure Database for MariaDB
- Django support for Microsoft SQL Server
- Azure Database for Postgres Pricing