Skip to content

Commit

Permalink
add dowtime prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrat2005 committed Feb 28, 2024
1 parent 5990569 commit 2b6fe1b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ function Start-AzBasicLoadBalancerUpgrade {
[Parameter(Mandatory = $false)][switch] $outputMigrationValiationObj,
[Parameter(Mandatory = $false)][int32] $defaultJobWaitTimeout = (New-Timespan -Minutes 10).TotalSeconds,
[Parameter(Mandatory = $false)][switch] $force,
[Parameter(Mandatory = $false)][boolean] $confirm = $true,
[Parameter(Mandatory = $false)][switch] $Pre
)

Expand All @@ -194,6 +195,20 @@ function Start-AzBasicLoadBalancerUpgrade {
Write-Error "The path '$recoveryBackupPath' specified with parameter recoveryBackupPath must exist and be a valid directory." -terminateOnError
}

# warn user about application downtime
If ((($confirm) -and !$force) -and !(Test-Path -Path (Join-Path -Path $RecoveryBackupPath -ChildPath 'Start-AzBasicLoadBalancerUpgrade.log'))) {
$message = "This operation will cause downtime for the application(s) using the Basic Load Balancer--usually a few minutes--see https://aka.ms/BasicLBMigrateDowntime. Are you sure you want to continue? [y/N]"
$result = Read-Host -Prompt $message
If ($result -ne 'y' -and $result -ne 'yes') {
Write-Host "Operation cancelled by user"
return
}
Else {
Write-Host -ForegroundColor Green "`nSpecify parameter ``-confirm `$false`` to skip this prompt in the future`n"
Start-Sleep -Seconds 2
}
}

log -Message "############################## Initializing Start-AzBasicLoadBalancerUpgrade ##############################"

log -Message "[Start-AzBasicLoadBalancerUpgrade] PowerShell Version: $($PSVersionTable.PSVersion.ToString())"
Expand Down

2 comments on commit 2b6fe1b

@cbellee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a more canonical way to prompt users on a particular action would be to use SupportsShouldProcess Method. You can access this functionality by adding the [CmdletBinding] attribute to functions.

Did you implement it this way because of this known issue?

@mbrat2005
Copy link
Contributor Author

@mbrat2005 mbrat2005 commented on 2b6fe1b Feb 29, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.