3

我在Visual Studio 2015中编写了一个Django项目,它在通过IDE进行调试时在本地服务器上成功运行。然而,当我...无法将Django项目从VS2015发布到Azure Web应用程序

  1. 右键单击Solution Explorer中的项目,并选择发布
  2. 选择Microsoft Azure Web Apps作为发布目标
  3. 点击新建...,进入细节打造在Azure上一个新的Web应用程序:
    • 具有相同的名称作为Web应用程序
    • 科瑞创建一个新的App Service Plan荷兰国际集团新Resource Group具有相同的名称作为Web应用程序
    • Region:北欧
    • Database server:没有数据库
  4. 点击创建
  5. 选择发布方法:Web Deploy并成功验证连接到新的Azure Web App
  6. Click Publish

... Output窗口显示,发布失败:

------ 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更新2 RC,但这也没有任何区别。

我也尝试在Python 3.4.4/Django 1.9.4虚拟环境中的VS2015的New Project窗口中创建示例Django Web Project,并且无法以完全相同的方式发布。

有没有人有任何建议,如何成功地发布一个Django项目从VS2015的Azure Web应用程序?

任何援助将不胜感激。

+0

我按照你的步骤在Visual Studio中创建了示例Django Web Project。添加了一个虚拟环境(Python 3.4,Django 1.9.4)。它发布到Azure Web应用程序没有任何错误。我可否知道您在虚拟环境中使用了哪个Python版本? –

+0

嗨甘达利,当我创建Django Web项目示例时,我使用了Python 3.4.4/Django 1.9.4虚拟环境。 – w5m

+0

@ w5m,我尝试按照以下步骤重现此问题: 1.创建Django项目并添加名为**'env'**的虚拟环境。 2.安装完所有依赖关系后重新生成requirements.txt文件。 3.使用VS部署网站,并按照你的描述和网站工作。您可以请遵循以下文档:https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/或者您可以使用GitHub来部署您的网站(http:// blog。 smarx.com/posts/tutorial-running-a-python-web-application-in-windows-azure) –

回答

1

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

右键单击下的溶液中的Python环境部分,单击添加虚拟环境

enter image description here

选择Python版本,标志着下载并安装软件包,单击创建按钮即可创建您的解决方案目录下的一个新的虚拟环境。 enter image description here

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

+0

感谢您的回应Gary。不幸的是,我已经为上述两个示例创建了虚拟环境(按照您所描述的方式)。如果我已将虚拟环境部署到Azure,我是否理解Azure Web应用程序服务的Python版本设置是不相关的(即,它甚至可以设置为OFF?)? – w5m

+1

是的,您的python应用程序将使用虚拟环境,但是如果您需要在Kudu Console站点或VSO或部署任务上运行任何python命令,它将利用azure上的python环境。 –

相关问题