通过 Visual Studio 2017 在 Azure 中部署 Django Web 应用程序

2022-01-12 00:00:00 python django azure visual-studio-2017

问题描述

我在 Visual Studio 2017 中使用 Django 制作了一个简单的应用程序,使用 Visual Studio 中的默认模板(文件 - 新建 - 项目 - python - django Web 应用程序).该应用程序在本地正常运行,但在我通过 Visual Studio 将其部署到 Azure 后,我只能访问显示的页面:

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.

所有文件都已正确上传(我可以在sitewwwroot"文件夹中看到它们),但该应用程序无法运行!

The files are all properly uploaded (i can see them in the 'sitewwwroot' folder), but the app doesn't work!

我已经尝试了我在搜索中可以找到的所有内容,例如:关注 this 教程;将.azurewebsites.net"添加到允许的主机,通过pip install azure"在我的项目虚拟环境中安装 azure sdk,将manage.py"添加到默认文档等等.

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.

问题是当我将我的 ASP.NET 应用程序部署到 Azure 时(以完全相同的方式:右键单击项目,选择发布,天蓝色...),它们可以以最小的努力正常工作.

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.

我很沮丧,因为我真的很喜欢 Django 框架和 Azure,请帮助.

I am very frustated, because i really like Django framework and Azure, please help.

提前致谢!


解决方案

经过一番努力我终于做到了!

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) 我在 Azure 中创建了一个 Django (PTVS) Web App;

1) I've created a Django (PTVS) Web App in Azure;

2) 关注 this 配置该应用程序的教程;

2) Followed this tutorial to configure that app;

3) 对我的项目中的 web.config 文件进行必要的调整,特别是通过扩展安装的 python 版本的路径;

3) Make the necessary adjustments to web.config file in my project, notably the path to the python version installed via extension;

4) 通过 Visual Studio 2017 将我的项目发布到第一步创建的 Django App.

4) Published my project via Visual Studio 2017 to that Django App created in the first step.

它成功了!

相关文章