1
我試圖通過在PowerShell中運行它來使用Move-AzureDeployment cmdlet交換服務器。它似乎需要大約4分鐘才能從分期轉換到生產。這就是4分鐘的停機時間,並不是真的可以接受。當我從Azure Portal手動交換服務器時,它幾乎是瞬間發生的。Move-AzureDeployment花費太長時間來交換服務器?
我想知道爲什麼它需要更長的時間使用cmdlet,我該怎麼做才能解決此問題,因爲我希望能夠使用powershell交換我的分段和生產服務器。
這裏是我的PowerShell腳本:
try
{
$ErrorActionPreference = "stop"
Write-Host "Deploying build build no. $env:build_number to $_serviceName"
#import azure cmdlets module
Write-Host "Importing azure service management modules (i.e for the old portal)"
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"
Write-Host "Started Command for Switching Slots"
#Switch slots from Staging to Production
Move-AzureDeployment -ServiceName $_serviceName
Write-Host "Finished Command for Switching Slots"
#make sure deployment is in running state
$deployment = Get-AzureDeployment -servicename $_serviceName -slot $_slotName
Write-Host "$_serviceName is in state $($deployment.status)"
$StopWatch = [System.Diagnostics.Stopwatch]::StartNew() #declare stopwatch
while (($deployment.Status -ne "running") -and ($StopWatch.Elapsed.Hours -lt 2)) #running the loop for a maximum of 2 hours
{
Write-Host "wait 5 seconds before trying again"
Start-Sleep -s 5
$deployment = Get-AzureDeployment -servicename $_serviceName -slot $_slotName
Write-Host "$_serviceName is in state $($deployment.status)"
}
#make sure all roles are in ready state
$nonReadyInstances = (Get-AzureDeployment $_serviceName -Slot $_slotName).RoleInstanceList | Where-Object { $_.InstanceStatus -ne "ReadyRole" } | ft -Property RoleName, InstanceName, InstanceStatus
$nonReadyInstances
$StopWatch = [System.Diagnostics.Stopwatch]::StartNew() #declare stopwatch
while (($nonReadyInstances -ne $null) -and ($StopWatch.Elapsed.Hours -lt 2)) #running the loop for a maximum of 2 hours
{
Write-Host "wait 5 seconds before trying again"
Start-Sleep -s 5
$nonReadyInstances = (Get-AzureDeployment $_serviceName -Slot $_slotName).RoleInstanceList | Where-Object { $_.InstanceStatus -ne "ReadyRole" }
$nonReadyInstances
}
#output deployment id
#$deploymentid = Check-Deployment -serviceName $_serviceName -slotName $_slotName
#Write-Host "Deployed to $_serviceName with deployment id $deploymentid and slot $_slotName"
exit 0
}
catch [System.Exception]
{
Write-Host $_.Exception.ToString()
exit 1
}
我與微軟支持代表交談過,他提到,雖然他們宣傳VIP交換是一種非停機操作,但實際上有一些與停機相關的事情,這就是我所看到的。想知道我們如何解決這個問題? – chillax786