tonybaloney / django-on-azure

Resources for my Django on Azure workshop at PyCon US 2021
MIT License
19 stars 6 forks source link
azd-templates azure django postgresql

Django on Azure sample repo

A copy of the slides from my Django on Azure PyCon US 2021 workshop is available in this repository.

Deployment

  1. 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:

  1. 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:

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), and azd 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.

Sections

Azure Architecture

Links

Azure Web Apps

App Service Pricing

App Service Components

Configuring ASGI workers

  1. 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
  1. Make sure you add uvicorn to the requirements.txt file
  2. Pick the right number of workers and threads for the instance size
  3. 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

Databases

Overview of DBaaS offerings

Types of Postgres Deployment on Azure

Other Useful Links

Content Delivery

Monitoring and Insights

Deployment and DevOps

Extra Components