在发布到Azure时,为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还是我们在Azure门户中设置了环境变量?在部署之间,这种情况会持续下去吗?
如果这很重要,我将使用ASP.NET 5 beta6库和dnx451目标框架。
发布于 2015-09-02 00:17:54
在发布到Azure时,为ASP.NET 5 web应用程序的每个部署设置环境名称是最好的吗?
@科里-福勒是对的。使用应用程序设置设置环境名称。至少有四种方法可以做到这一点。
portal.azure.com
浏览>所有资源> MyApp >设置>应用程序设置。
manage.windowsazure.net
网络应用> 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 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如您所见,使用PowerShell比使用CLI要复杂得多。注意:安装Azure PowerShell后重新启动控制台窗口。
发布于 2015-08-26 09:00:42
应用程序设置在部署之间肯定会持续存在,它们是区分云中环境的一种很好的方法。
我在2012年写了一篇关于这件事的博文。在App与云服务中使用环境变量
https://stackoverflow.com/questions/32218500
复制相似问题