gpt4 book ai didi

powershell - Move-Azure 部署交换服务器花费的时间太长?

转载 作者:行者123 更新时间:2023-12-03 04:30:31 25 4
gpt4 key购买 nike

我正在尝试通过在 powershell 中运行 Move-AzureDeployment cmdlet 来交换服务器。从暂存切换到生产似乎需要大约 4 分钟。那是 4 分钟的停机时间,这是 Not Acceptable 。当我从 Azure 门户手动交换服务器时,它几乎立即发生。

我想知道为什么使用 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 交换,因为它们都在运行。微软表示,您不应该在网站/应用程序本身上看到任何停机时间。请求仍将到达旧的生产服务器,直到更改完成。您在交换期间是否发现站点出现停机?

关于powershell - Move-Azure 部署交换服务器花费的时间太长?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37419239/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com