Lut*_*ndo 8 powershell azure asp.net-core
如何将我的ASP.NET核心应用程序发布到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
Run Code Online (Sandbox Code Playgroud)
现在,此脚本将调用default-publish.ps1脚本,前提是您提供了Azure网站名称和dotnet发布工件.我已将default-publish.ps1脚本更新为目前repo中的内容.
问题是,当我发布到Azure时,会返回502 Bad Gateway错误.即使使用新工具更新创建的项目,我似乎也无法正确地将其发布到Azure.
你有 web.config 吗?它是否包含在您的project.json中,如下所示:
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
}
Run Code Online (Sandbox Code Playgroud)
你的 web.config 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule"
resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
注意:环境变量 LAUNCHER_PATH 和 LAUNCHER_ARGS 可能是问题的根源。您正在尝试启动 Visual Studio 运行的发布脚本,Visual Studio 可能会在运行脚本之前设置环境中的值。
为了在 Azure VM 上启动并运行 RC2 站点,我必须将该行更改为如下所示:
<aspNetCore processPath="dotnet" arguments="./YourAppEntryPoint.dll"
stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false"/>
Run Code Online (Sandbox Code Playgroud)
尝试使用显式值设置 web.config。如果您的部署有效,那么您就知道是缺少 ENVVARS 造成了混乱。
| 归档时间: |
|
| 查看次数: |
575 次 |
| 最近记录: |