I've made a simple app with Django in Visual Studio 2017, utilizing the default template in Visual Studio (file - new - project - python - django web application).
The app runs properly locally, but after i deploy it to Azure via Visual Studio, i can only access the page that shows:
Your App Service app has been created.
The files are all properly uploaded (i can see them in the 'site\wwwroot' folder), but the app doesn't work!
I have tried every thing that i was able to find in my searches such as: following this tutorial; adding '.azurewebsites.net' to the allowed hosts, installing azure sdk in my project virtual environment via: 'pip install azure', adding 'manage.py' to default documents, among many other things.
The thing is when i deploy (in the exact same way: right click the project, select publish, azure...) my ASP.NET apps to Azure, they work properly with minimum effort.
I am very frustated, because i really like Django framework and Azure, please help.
Thanks in advance!
In consideration of using Visual Studio to create & deploy a Django App for Azure, I suggest that you can follow the Azure offical tutorial Django and MySQL on Azure with Python Tools 2.2 for Visual Studio to inspect & make sure your steps correctly.
There are some checkpoints as below.
Make sure PTVS installed correctly, please move to here to know more details of PTVS.
Create a virtual environment for a Python version like 2.7 via PTVS.
Edit the requirements.txt file of your project, and make sure there is a record for Django like Django==1.11.2.
When you want to deploy it to Azure WebApps, please check the Python version for Azure WebApps that is the same with your project.
If your Django App doesn't still work as you want, please refer to the document to check the configuration of the web.config file via access the Kudu tool https://<your app name>.scm.azurewebsites.net and other troubleshooting content, and refer to the document to check the application settings on Azure portal.
Hope it helps. Any concern, please feel free to let me know.
After much struggle i manage to to do it!
I will explain how i did it (i've used many tutorials and forum posts answers to achieve this):
1) I've created a Django (PTVS) Web App in Azure;
2) Followed this tutorial to configure that app;
3) Make the necessary adjustments to web.config file in my project, notably the path to the python version installed via extension;
4) Published my project via Visual Studio 2017 to that Django App created in the first step.
And it worked!
Related
I am trying to deploy a Python Django application to Azure Cloud Services with Visual Studio 2022.
My Visual Studio install includes the Python module "Azure Cloud Services core tools", along with the rest of the Python development tools.
However, no Python project template for Azure is not available to me. I only have C# and Visual Basic for Azure Cloud Service (classic and extended).
How can I build the Cloud Service in Visual Studio?
Initially Iam unable to find Django Template in VS2022.
Click on the Install more tools and features option
Visual Studio Installer will be opened to Modify the Workloads
Select the option for Python development , make sure you have selected all the Optional check boxes under Python Development and click on Modify
Selected workloads will be Installed
Now you can see the Django Web Templates available
I have created a sample Django Web App ,right click on the Solution Explorer and click on Publish, Iam able to see the option to publish to Azure
AFAIK, there is no separate template available for Azure, we need to select the Django Web Project and Publish to Azure from there.
Currently my Azure Function shows a different file version in the portal as compared to Kudu.
I am using Azure App Service /w Azure Functions V2 and Python 3.7.
I publish my function app using:
func azure functionapp publish <functionappname>
It successfully performs a remote build.
Now if I look at my Function App in the portal I can see the updated version of my init.py. However, when I use Kudu (Platform features > Advanced tools (Kudu)) to look into the file /home/site/wwwroot//init.py I still see the old version. Shouldn't these versions be identical?
I hope some experienced user can shed light on this.
I test it in my side, when I create a new azure function app(python) and deploy the python code from VS Code to azure portal. It will not create a "init.py" under the directory /home/site/wwwroot. In this directory, it just exists a "host.json"(shown as below).
So you can see the new version of your "init.py" after your deployment on azure portal, but it seems the old version "init.py" in the directory /home/site/wwwroot may be created by a deployment in the past or created because some other reasons in the past. I think it has nothing to do with your new deployment.
I have a existing django web application currently deployed on aws. I want to deploy it on Microsoft Azure by using cloud services. How to create config files for deploying web app on Azure? How to access environment variables on Azure? I am not using Visual Studio. I am developing web app in linux env and using git for code management. Please help
It sounds like you want to know which way is the best choice for deploying a django app via Git for code management on Linux, using Cloud Services or App Services on Azure.
Per my experience, I think deploying a pure web app into App Service on Azure via Git on Linux is the simplest way for you. You can refer to the offical docuemnts below to know how to do it via Azure CLI or only Git.
Deploy your first Python web app to Azure in five minutes
Local Git Deployment to Azure App Service
And there is a code sample of Django on App Service as reference that you can know how to configure it for running on Azure.
However, if your app need more powerful features & performance, using Cloud Services for your django app is also a better way than using VM directly. Also as references, please view the document Python web and worker roles with Python Tools for Visual Studio to know how to let Azure support Python & Django on Cloud Services, and you can create & deploy it via Azure portal in the browser on Linux. Meanwhile, thanks for the third party GitHub sample of Django WebRole for Cloud Service which you can refer to know how to create a cloud service project structure without PTVS for VS on Linux.
Hope it helps.
I read this post, decided the how-to guides Peter Pan posted looked good, and set off on my own. With my one business day's worth of experience if you are looking to deploy your app to Azure, start with the Marketplace Django app and go from there. Reason being the virtual environment comes with it along with the activate script needed to run the virtual environment and the web.config is setup for you. If you follow the start from scratch how-to guides, these are the hardest parts to setup correctly. Once you create the app service from the template, do a git clone of the repo to your local machine. Make a small change and push it back up by running the command below in bash.
az webapp deployment source config-local-git --name <app name> --resource-group <group name> --query url --output tsv
Use the result of the command to add the git repo as a remote source.
git remote add azure https://<ftp_credential>#<app_name>.scm.azurewebsites.net/<app_name>.git
Finally, commit your changes and deploy
git add -A
git commit -m "Test change"
git push azure remote
A couple of side notes
If you do not have your bash environment setup, you'll need to do so to use the az commands. The marketplace app does run error-free locally. I have not dug into this yet.
Good luck!
i'm using the PyCharm IDE, and I am trying to import webapp2 from the google app engine SDK. Since the module does not come with python, it doesn't recognize it "No module named webapp2".. I am using the pycharm community version, is there anyway around this? can I import the SDK somehow?
PyCharm Community Edition can be configured to work with Google App Engine python and hence webapp2. You won't get all the advantages of PyCharm Professional Edition such as deployment, but you'll be able to do step by step debugging and get code navigation and auto-completion working.
To enable debugging, edit the PyCharm Run/Debug configuration by setting:
Script: App Engine's dev_appserver.py
Script parameters: --automatic_restart=no --max_module_instances="default:1" .
Working directory: your base project folder (the one which contains the app.yaml file)
For more detailed instructions, explanations, and how get code completion working in your PyCharm CE project, see this tutorial.
PyCharm Community Edition does not have support for Google App Engine.
Reference: PyCharm Editions Comparison
Here's the guide which can help you to install webapp2: Quick start (to use webapp2 outside of App Engine)
Note: webapp2 is just the first step, and you will miss PyCharm integration with Google App Engine. If your project requires other Google App Engine services, consider investment into Professional version of PyCharm.
I'm using PyCharm (webApp2 library) with google app engine and I tried to found the best way for debug by python code,
that's what I found:
There is two main options:
PDB (python debugger) - GAE tool for run & debug your code which is default installed in your GAE directory (dev_appserver.py).
The tool allows you to run your program from cmd and debug it manually.
"import pdb" to your python code
use the "pdb.set_trace()" command for put a breakpoint
use cmd to run the program cd <google_appengine_dir>
python dev_appserver.py <your_project_path>
for ins cd C:\Program Files (x86)\Google\google_appengine
python dev_appserver.py C:\projects\myapp
[pbd syntax][1]
insert pdb to your python code
The second and the my preferred option is to use the pycharm build-in debugger tool. All you need to do is to use the script dev_appserver.py in the pycharm debug configuration.
Configure python GAE debugging
If you consider to upgrade to a professional version of PyCharm (or use the 30 days test-license) you can find here a guide for PyCharm showing how to create a google app engine project:
Getting Started with PyCharm as Google App Engine IDE
Before your can create the project you have to download and install the google app engine sdk depending on your platform and which language you want to use:
Download the Google App Engine SDK
I normally use Java development and the Google Eclipse plugin, which integrates GoogleAppEngine deploy capability.
Now I have found a Python application with source code that I want to bring into Eclipse and deploy from Eclipse, but I don't even know if Eclipse supports Python.
What do I have to do to deploy the Python app to GAE ?
Download PyDev from its Eclipse update site.
Create a new PyDev Google App Engine Project, say using the 'Hello webapp world' template.
Set the application in app.yaml to your GAE application ID.
Right-click the src folder of your project and select Run As | PyDev:Google App Run.
Test the application works as expected in your browser.
Right-click the src folder of your project and select PyDev:Google App Engine | Upload. Follow the prompts.
Check that it works on your GAE site.
Replace the hello webapp world code with your actual application's code and retest locally, then upload again and test.
Take a look at Pydev - http://pydev.org/
I haven't used python via Eclipse at all so I'm not sure how things map to the way Eclipse deploys, but generally to deploy all you need to do is this from the command line:
appcfg.py update <app directory>
You can find more help about using Python with appengine here:
http://code.google.com/appengine/docs/python/gettingstarted/