【问题标题】:Unable to publish Django project to Azure Web App from VS2015无法从 VS2015 将 Django 项目发布到 Azure Web App
【发布时间】:2016-03-07 15:30:24
【问题描述】:

我在 Visual Studio 2015 中编写了一个 Django 项目,当通过 IDE 进行调试时,它可以在本地服务器上成功运行。但是,当我...

  1. 在解决方案资源管理器中右键单击项目并选择发布
  2. 选择Microsoft Azure Web Apps作为发布目标
  3. 单击 New... 并输入详细信息以在 Azure 上创建新的 Web 应用程序:
    • 创建一个与 Web 应用同名的新 App Service Plan
    • 创建一个与 Web 应用同名的新 Resource Group
    • Region: 北欧
    • Database server: 没有数据库
  4. 点击创建
  5. 选择发布方法:Web Deploy 并成功验证连接到新的 Azure Web 应用
  6. 点击发布

...输出窗口显示发布失败:

------ Publish started: Project: RaceLogger, Configuration: Debug Any CPU ------
Validating Web Deploy package/publish related properties...
Gather all files from Project items @(Content). Adding:
app\templates\app\performance_form.html;app\templates\auth\login.html;app\templates\index.html;app\templates\layout.html;app\templates\app\performance_detail.html;app\templates\app\performance_list.html;requirements.txt
Gather all files from Project output (IntermediateSatelliteAssembliesWithTargetPath). Adding:
Gather all files from Project items @(ReferenceCopyLocalPaths,ReferenceComWrappersToCopyLocal,ResolvedIsolatedComModules,_DeploymentLooseManifestFile,NativeReferenceFile).
Gather all files from Project items @(AllExtraReferenceFiles). Adding:
Gather all files from Project items @(_binDeployableAssemblies). Adding:
DjangoStaticUrlSetting=/static/
Regenerating web.config
Copying file from "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Python Tools\web_config.xml" to "obj\Debug\web.config".
Updating app settings in web.config
Made 1 replacement(s).
Updating rewrite conditions in web.config
Made 1 replacement(s).
Updating FastCGI handlers in web.config
Made 1 replacement(s).
Copying file from "obj\Debug\web.config" to "C:\Users\username\Documents\Files\Web_Projects\django\RaceLoggerProject\RaceLogger\web.config".
Regenerating web.debug.config
Copying file from "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Python Tools\web_debug_config.xml" to "obj\Debug\web.debug.config".
Updating ptvsd secret in web.debug.config
Made 1 replacement(s).
Copying file from "obj\Debug\web.debug.config" to "C:\Users\username\Documents\Files\Web_Projects\django\RaceLoggerProject\RaceLogger\web.debug.config".

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

我检查了新创建的 Azure Web 应用程序是否正在通过 Azure 管理门户运行,并修改了 Web 应用程序的 Application settings 以便选择 Python 3.4 版(在我的本地环境中,我正在运行 Python 3.4.4和 Django 1.9.3) 无济于事。我试过更新到 VS2015 Update 2 RC,但这也没什么区别。

我还尝试在 Python 3.4.4 / Django 1.9.4 虚拟环境中创建 VS2015 的“新建项目”窗口中可用的示例 Django Web Project,但无法以完全相同的方式发布。

有人对如何从 VS2015 成功将 Django 项目发布到 Azure Web App 有任何建议吗?

任何帮助将不胜感激。

【问题讨论】:

  • 我按照您的步骤在 Visual Studio 中创建了示例 Django Web 项目。添加了一个虚拟环境(Python 3.4、Django 1.9.4)。并且它没有任何错误地发布到 Azure Web 应用程序。请问您在虚拟环境中使用的是哪个 Python 版本?
  • 您好 Gandhali,当我创建示例 Django Web 项目时,我使用了 Python 3.4.4 / Django 1.9.4 虚拟环境。
  • @w5m,我尝试按照以下步骤重现此问题: 1. 创建 Django 项目并添加名为 'env' 的虚拟环境。 2. 安装完所有依赖后重新生成requirement.txt文件。 3.使用VS部署网站并按照您的描述和网站工作。请您关注文档:azure.microsoft.com/en-us/documentation/articles/… 或者您可以使用 GitHub 部署您的网站 (blog.smarx.com/posts/…)

标签: python django azure visual-studio-2015 azure-web-app-service


【解决方案1】:

您是否尝试过使用虚拟环境来指定您的 Python 版本,不受 Azure Web Apps Service 上 Python 版本的限制。

右键点击解决方案下的Python Environments部分,点击Add Virtual Environment。

选择python版本,标记下载并安装包,点击创建按钮在你的解决方案目录下创建一个新的虚拟环境。

按 F5 进行调试以测试应用程序,然后尝试再次部署到 Azure。

【讨论】:

  • 感谢您的回复加里。不幸的是,我已经为上面的两个示例创建了虚拟环境(以您描述的方式)。如果我已将虚拟环境部署到 Azure,我是否理解 Azure Web App Service 的 Python 版本设置无关紧要(即,它甚至可以设置为 OFF?)?
  • 是的,您的 python 应用程序将使用虚拟环境,但如果您需要在 Kudu 控制台站点或 VSO 或部署任务上运行任何 python 命令,它将利用 azure 上的 python 环境。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多