Where is it best to set the environment name for each deployment of a ASP.NET 5 web application when publishing to Azure Web Apps?
I understand that the ASPNET_DEV
environment variable needs to be set. Is this possible on publish?
This is our powershell publish script:
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
Or do we have set the environmental variable in the Azure portal? Will this persist between deployments?
I am using the ASP.NET 5 beta6 libraries with the dnx451
target framework, if that matters.
Where is it best to set the environment name for each deployment of a ASP.NET 5 web application when publishing to Azure Web Apps?
@cory-fowler is right. Use App Settings to set the environment name. There are at least four ways to do that.
Browse > All resources > MyApp > Settings > Application settings.
Web apps > MyApp > CONFIGURE > app settings.
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
As you can see, it is trickier with PowerShell than with the CLI. Note: restart the console window after installing Azure PowerShell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With