[英]Azure DevOps Pipeline to non-Azure site via FTP App_Offline
Without the App_Offline you can't overwrite the.dll bits of the active site, and I can't get it to delete them either, so I definitely need to take the site offline.如果没有 App_Offline,您将无法覆盖活动站点的 .dll 位,我也无法删除它们,因此我肯定需要使站点脱机。 I do not want to do that manually as it makes the pipeline less useful.
我不想手动执行此操作,因为它会降低管道的用处。
I can't be the only/ first person to need to do this - does anyone have some YAML which will do that specific job please?我不能是唯一/第一个需要这样做的人 - 有没有人有一些 YAML 可以完成这项特定工作?
You can use "EnableMSDeployAppOffline" feature to set your app offline before deployment by following the instruction here: Web publishing updates for app offline and usechecksum .您可以按照此处的说明使用“EnableMSDeployAppOffline”功能在部署之前将您的应用程序设置为离线: Web 发布应用程序离线更新和使用校验和。
If it does not work, you can also add a PowerShell task to run script as following to stop the app, deploy and then restart the app:如果它不起作用,您还可以添加一个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 "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"
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName
See thread: VSTS - Take app offline before deployment for more details.有关详细信息,请参阅线程: VSTS - 在部署之前使应用程序脱机。
I got the upload to work...我让上传工作...
Step 1: Add an App_Offline.htm file to the repo第 1 步:将 App_Offline.htm 文件添加到 repo
Step 2: add an initial FTP step to take the site offline before the ftp upload of the site itself.第 2 步:添加一个初始 FTP 步骤以在站点本身的 ftp 上传之前使站点脱机。 Like this (settings are similar to those used for the actual deployment ftp, except for the filePatterns):
像这样(设置与实际部署ftp使用的设置类似,除了filePatterns):
- task: FtpUpload@2
inputs:
credentialsOption: 'inputs'
serverUrl: 'ftp://ftpx.ftptothesite.com' # 3rd party hoster site address
username: '$(ftpUsername)'
password: '$(ftpPassword)'
rootDirectory: '$(Build.ArtifactStagingDirectory)/s'
filePatterns: 'app_offline.htm'
remoteDirectory: '/web/content/'
preservePaths: true
trustSSL: true
displayName: 'Take site offline'
That makes the upload work, but leaves the remote site offline (because there's an app_offline.htm in the root there).这使得上传工作,但使远程站点脱机(因为那里的根目录中有一个 app_offline.htm)。
Step3: Delete app_offline.htm Note that the FTP task has a "customCmds" parameter which MS describe as:第三步:删除 app_offline.htm 注意 FTP 任务有一个“customCmds”参数,MS 描述为:
Optional FTP Commands that will be sent to the remote FTP server upon connection
可选 FTP连接后将发送到远程 FTP 服务器的命令
My italics.我的斜体。 The custom commands are run before the FTP task they are defined in, not after.
自定义命令在定义它们的 FTP 任务之前运行,而不是之后。 Hence I needed one more FTP upload task, of something benign, but with a
DELE /web/content/app_offline.htm
as the last command.因此,我需要另外一个 FTP 上传任务,这是良性的,但最后一个命令是
DELE /web/content/app_offline.htm
。 Note that the full path is needed, presumably as this runs before the remoteDirectory is set up.请注意,需要完整路径,大概是因为它在设置 remoteDirectory 之前运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.