Skip to content

Commit

Permalink
HACK: Add sleeps.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej committed Jan 22, 2022
1 parent 5e135ae commit 80fb6c7
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions azure-devops/create-vmss.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $ImageOffer = 'windows-11'
$ImageSku = 'win11-21h2-ent'

$ProgressActivity = 'Creating Scale Set'
$TotalProgress = 14
$TotalProgress = 17
$CurrentProgress = 1

<#
Expand Down Expand Up @@ -268,6 +268,14 @@ $IgnoredAzureOperationResponse = New-AzVm `
-Location $Location `
-VM $VM

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Sleeping for 2 minutes after creation, before provision-image.ps1' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)

Start-Sleep -Seconds 120

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
Expand All @@ -283,6 +291,14 @@ $ProvisionImageResult = Invoke-AzVMRunCommand `

Write-Host "provision-image.ps1 output: $($ProvisionImageResult.value.Message)"

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Sleeping for 2 minutes after provision-image.ps1, before restart' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)

Start-Sleep -Seconds 120

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
Expand All @@ -294,12 +310,12 @@ $IgnoredComputeLongRunningOperation = Restart-AzVM -ResourceGroupName $ResourceG
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Sleeping after restart' `
-Status 'Sleeping for 2 minutes after restart, before sysprep.ps1' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)

# The VM appears to be busy immediately after restarting.
# This workaround waits for a minute before attempting to run sysprep.ps1.
Start-Sleep -Seconds 60
# This workaround waits for 2 minutes before attempting to run sysprep.ps1.
Start-Sleep -Seconds 120

####################################################################################################
Write-Progress `
Expand All @@ -321,6 +337,14 @@ Write-Progress `

Wait-Shutdown -ResourceGroupName $ResourceGroupName -Name $ProtoVMName

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
-Status 'Sleeping for 2 minutes after sysprep shutdown, before imaging' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)

Start-Sleep -Seconds 120

####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
Expand Down

0 comments on commit 80fb6c7

Please sign in to comment.