【发布时间】:2015-12-13 21:55:33
【问题描述】:
当使用以下 Powershell 脚本发布到我们的 Azure Web 应用程序时,我们经常会遇到问题,即之前发布的文件会导致运行时错误。
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 "Stopping web app..."
Stop-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"
Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
如何在发布前删除所有现有文件?
请注意,我们不能使用槽,因为这需要标准实例,这对于我们的 CI 环境来说太昂贵了。
【问题讨论】:
标签: powershell azure azure-web-app-service msdeploy azure-powershell