- Create Sample Project
- Create Azure WebApp and Use Site Extension to Upgrade Python
- Create Deployment script
- Change Deployment script
- Copy necessary files
- Publish App
You can find a Sample Python Django project with above operations @ GitHub Link
Create Sample Project
Follow https://www.djangoproject.com/start/ to get started with Django
- Install Django and
- Create your first project
(or)
If you have PyCharm, Follow details at below link to create a sample app
https://www.jetbrains.com/help/pycharm/2016.1/creating-django-project.html
Create Azure WebApp and Use Site Extension to Upgrade Python
Navigate to Azure portal
- Create a new web app
- Setup Continuous Deployment
Follow below blog on how to upgrade python using site extension
https://blogs.msdn.microsoft.com/pythonengineering/2016/08/04/upgrading-python-on-azure-app-service/
As Steve has mentioned in his blog at above link, add site extension to your web app.
For this blog I’m choosing Python 2.7.12 x64
, It would install new version of python @ D:\home\Python27
Create Deployment script
I have explained more on how to utilize deployment script and what it does @link
Install Azure Cli using below command
npm install azure-cli -g
Use Below command to create deployment script.
azure site deploymentscript --python
Above step would create below two files
- .deployment
- deploy.cmd
Change Deployment script Content
Replace content of deploy.cmd file with content at Link
I have changed the code to utilize new python executable available @ D:\home\Python27
Copy necessary files
Create below two new files at root folder and copy content from link
web.config
– used to configure IISptvs_virtualenv_proxy.py
– Helper python file to activate virtual environment
Create requirements.txt file and add app required modules in it. you can find a sample @ link
Publish App
Navigate to your root folder and commit your changes to WEB_APP_GIT_URL
git init
git add .
git commit -m "initial commit"
git remote add sampledjangoapp WEB_APP_GIT_URL
git push sampledjangoapp master
Here is my App on Azure After publish
You can find a Sample Python Django project with above operations @ GitHub Link
Join the conversation
Add Comment