首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure中的ASP.NET 5环境名称

Azure中的ASP.NET 5环境名称
EN

Stack Overflow用户
提问于 2015-08-26 05:19:24
回答 2查看 2.4K关注 0票数 12

在发布到Azure时,为ASP.NET 5 web应用程序的每个部署设置环境名称是最好的吗?

我理解需要设置ASPNET_DEV环境变量。这在出版的时候有可能吗?

这是我们的powershell发布脚本:

代码语言:javascript
复制
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目标框架。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-09-02 00:17:54

在发布到Azure时,为ASP.NET 5 web应用程序的每个部署设置环境名称是最好的吗?

@科里-福勒是对的。使用应用程序设置设置环境名称。至少有四种方法可以做到这一点。

portal.azure.com

浏览>所有资源> MyApp >设置>应用程序设置。

manage.windowsazure.net

网络应用> MyApp >配置>应用程序设置。

Azure命令行接口(CLI)

代码语言:javascript
复制
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 

Azure PowerShell

代码语言:javascript
复制
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后重新启动控制台窗口。

票数 8
EN

Stack Overflow用户

发布于 2015-08-26 09:00:42

应用程序设置在部署之间肯定会持续存在,它们是区分云中环境的一种很好的方法。

我在2012年写了一篇关于这件事的博文。在App与云服务中使用环境变量

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32218500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档