【发布时间】:2016-05-24 13:10:57
【问题描述】:
如何将我的 ASP.NET Core 应用程序发布到 Azure?
到目前为止,我所做的是创建了一个脚本,该脚本是我从 Azure/Microsoft 官方文档中获得的,它调用 Visual Studio 也使用的 default-publish.ps1 脚本。脚本如下:
param($websiteName, $packOutput)
$website = Get-AzureWebsite -Name $websiteName
# get the scm url to use with MSDeploy. By default this will be the second in the array
$msdeployurl = $website.EnabledHostNames[1]
$publishProperties = @{'WebPublishMethod'='MSDeploy';
'MSDeployServiceUrl'=$msdeployurl;
'DeployIisAppPath'=$website.Name;
'Username'=$website.PublishingUsername;
'Password'=$website.PublishingPassword}
$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
现在,如果您提供 Azure 网站名称和 dotnet 发布工件,此脚本将调用 default-publish.ps1 脚本。我已将我的 default-publish.ps1 脚本更新为 repo 中的当前脚本。
问题是当我发布到 Azure 时返回 502 Bad Gateway 错误。即使使用新工具更新创建的项目,我似乎也无法将其正确发布到 Azure。
【问题讨论】:
-
网关错误很可能意味着您的应用程序根本没有启动。在将应用程序部署到 Azure 之前如何发布它?发布应用程序后,您的 web.config 看起来如何?我认为发生的事情是您的 web.config 只有占位符值。开箱即用的应用程序设置为在发布应用程序以修复您的配置后运行 publish-iis 工具。我认为要么这一步没有发生,要么 - 如果你从 RC1 移动到 RC2 - web.config 不在正确的位置,因为它现在应该在 approot 而不是 wwwroot。
-
我们在 CI 上有一个脚本,它运行 dotnet restore、dotnet build 和 dotnet publish 到一个位置,然后我们使用文章中提到的 repo 中的 vs publish 脚本来执行实际操作天蓝色部署。这个项目从一开始就一直是 RC2 webconfig 是您通过新的 VS 工具更新启动一个新的 RC2 项目时获得的默认配置。 web.config 位于启动.cs 和 program.cs 旁边的 approot 中。
-
我写了一篇关于使用 IIS 运行 ASP.NET Core 应用程序的帖子,其中包含有关 502.3 Bad Gatway 故障排除的整个部分:blog.3d-logic.com/2016/06/08/…。您可能会发现它很有帮助。
标签: powershell azure asp.net-core