Created
August 8, 2019 14:44
-
-
Save phaniav/fed9f2761aae5a5bbf4b1dfebff072f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory=$true)] | |
[string]$ResourceGroupName, | |
[Parameter(Mandatory=$true)] | |
[string]$AppServiceName | |
) | |
. "https://gist.githubusercontent.com/phaniav/6ada460d24cafedd4f6803da66e575d7/raw/90b335930a24667ff12ff75241956eecc4358630/Get-KuduUtility.ps1" | |
$folderKey = -join ((97..122) | Get-Random -Count 10 | ForEach-Object {[char]$_}) | |
$accessKey = -join ((97..122) | Get-Random -Count 10 | ForEach-Object {[char]$_}) | |
try{ | |
(Get-Content "https://gist.githubusercontent.com/phaniav/1d36a507dda8407c960639a49978ffd5/raw/bacb529fe6a3826f78033ef1a6d769af7e76a143/PublishManager.asmx").Replace("[TOKEN]", $accessKey) | Set-Content "$PSScriptRoot\tmp.asmx" | |
Write-FileFromPathToWebApp -resourceGroupName $ResourceGroupName -webAppName $AppServiceName -slotName "" -filePath "$PSScriptRoot\tmp.asmx" -kuduPath "PublishManager/$folderKey/PublishManager.asmx" | |
Remove-Item "$PSScriptRoot\tmp.asmx" -Force | |
$site = Get-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $AppServiceName | |
$webURI= "https://$($site.HostNames | Select-Object -Last 1)/PublishManager/$folderKey/PublishManager.asmx?WSDL" | |
try{ | |
$null = Invoke-WebRequest -Uri $webURI -UseBasicParsing | |
}catch{ | |
$null = Invoke-WebRequest -Uri $webURI -UseBasicParsing | |
} | |
$proxy = New-WebServiceProxy -uri $webURI | |
$proxy.Timeout = 1800000 | |
$ready = $proxy.PublishAll($accessKey) | |
if (-not $ready){ | |
throw "Unable to publish, check server logs for details." | |
} | |
Write-Host "Starting publish process and scanning for progress." | |
for ($i = 0; $i -lt 180; $i++) { | |
$done = $true | |
$proxy.PublishStatus() | ForEach-Object { | |
$done = $false | |
write-host $_ | |
} | |
write-host "*********** $($i * 20) Seconds **********" | |
if ($done){ | |
Write-Host "Publish Completed." | |
break | |
} | |
Start-Sleep -Seconds 20 | |
if ($i -eq 179){ | |
write-host "Sitecore Publish Timeout." | |
} | |
} | |
}finally{ | |
Write-Host "Removing Sitecore Publish service" | |
Remove-FileFromWebApp -resourceGroupName $ResourceGroupName -webAppName $AppServiceName -slotName "" -kuduPath "PublishManager/$folderKey/PublishManager.asmx" | |
Remove-FileFromWebApp -resourceGroupName $ResourceGroupName -webAppName $AppServiceName -slotName "" -kuduPath "PublishManager/$folderKey" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment