Notes of using Django in Azure App Service

Datetime:2016-08-22 22:25:27          Topic: Windows Azure  Django           Share

DebugConsole

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

Just go to https://{YOUR_PROJECT_NAME}.scm.azurewebsites.net/DebugConsole

Migrate django database

Exceute:

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

Create super user

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

Adjest timezone

Go to azure portal ,

WEBSITE_TIME_ZONE

Set WEBSITE_TIME_ZONE to anyvalue defined in here: https://technet.microsoft.com/en-us/library/cc749073(v=ws.10).aspx

Create Django Project

https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-django-app/

  1. Create Azure Django App (+ New) >

  2. Set enable git deployment / Config credentials

  3. Get git clone url, ex: https://cm1admin@cm1-django.scm.azurewebsites.net:443/cm1-django.git

  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

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




About List