Dav*_*New 10 azure azure-web-sites asp.net-core-mvc dnx asp.net-core
在发布到Azure Web Apps时,最好为ASP.NET 5 Web应用程序的每个部署设置环境名称?
我知道ASPNET_DEV需要设置环境变量.发布时这可能吗?
这是我们的powershell发布脚本:
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}
Write-Output "Restarting web app..."
Restart-AzureWebsite -Name $websiteName
Write-Output "Publishing web app..."
$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)
或者我们是否在Azure门户中设置了环境变量?部署之间会持续存在吗?
我正在使用ASP.NET 5 beta6库与dnx451目标框架,如果这很重要.
在发布到Azure Web Apps时,最好为ASP.NET 5 Web应用程序的每个部署设置环境名称?
@ cory-fowler是对的.使用"应用程序设置"设置环境名称.至少有四种方法可以做到这一点.
浏览>所有资源> MyApp>设置>应用程序设置.
网络应用> MyApp>配置>应用设置.
npm install -g azure-cli
azure account download
azure account import '~\Downloads\my-credentials.publishsettings'
site appsetting add ASPNET_ENV=Test MyApp
azure site appsettings list MyApp
Run Code Online (Sandbox Code Playgroud)
choco install -y windowsazurepowershell
Get-AzurePublishSettingsFile
Import-AzurePublishSettingsFile '~\Downloads\my-credentials.publishsettings'
$hash = (Get-AzureWebsite -Name "MyApp").AppSettings
$hash.Add("ASPNET_ENV", "Test")
Set-AzureWebsite -Name "MyApp" -AppSettings $hash
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,使用PowerShell比使用CLI更棘手.注意:安装Azure PowerShell后重新启动控制台窗口.
| 归档时间: |
|
| 查看次数: |
1835 次 |
| 最近记录: |