Cody Blog

Software development

Notes of using Django in Azure App Service


There is an debug conolse that you can exectue some commands for Django related tasks. The debug console is:


Migrate django database in Azure

  1. Go to D:\home\site\wwwroot directory

  2. Exceute migrate command

    D:\home\site\wwwroot> .\env\Scripts\python.exe migrate

Create super user

echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '', 'your_password')" | python shell

Adjest timezone

Go to azure portal,


Set WEBSITE_TIME_ZONE to anyvalue defined in here:

Create Django Project


  1. Create Azure Django App (+ New) >

  2. Set enable git deployment / Config credentials

  3. Get git clone url, ex:

  4. git push

Set static file

Edit your web.config in repository root folder:

In the following cases, we map /static and /uploads to static and uploads in repository

    <rule name="Static Files" stopProcessing="true">
        <add input="true" pattern="false" />
    <rule name="Configure Python" stopProcessing="true">
        <match url="(.*)" ignoreCase="false" />
        <add input="{REQUEST_URI}" pattern="^/(static|uploads)/.*" ignoreCase="true" negate="true" />
        <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />

DevOps Azure

Related Posts