Skip to content

fix: revert use azcli login for azcopy in windows#8050

Merged
awesomenix merged 1 commit intomainfrom
revert-8047-nishp/fix/azcopy_scripts
Mar 10, 2026
Merged

fix: revert use azcli login for azcopy in windows#8050
awesomenix merged 1 commit intomainfrom
revert-8047-nishp/fix/azcopy_scripts

Conversation

@awesomenix
Copy link
Contributor

Reverts #8047

Copilot AI review requested due to automatic review settings March 10, 2026 01:36
@awesomenix awesomenix changed the title Revert "fix: use azcli login for azcopy in windows" fix: revert use azcli login for azcopy in windows Mar 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts the prior change that configured AzCopy to use Azure CLI–based authentication on Windows, restoring MSI-based authentication for AzCopy usage in Windows VHD build and Windows e2e log upload paths.

Changes:

  • Windows VHD build: stop setting AzCopy AZCLI auto-login env vars and explicitly run azcopy login with --login-type=MSI.
  • Windows e2e log upload: switch AzCopy auto-login to MSI and remove the explicit azcopy login call.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
vhdbuilder/packer/windows/configure-windows-vhd.ps1 Updates AzCopy authentication from AZCLI env-based auto-login to explicit MSI login during VHD build downloads.
e2e/vmss.go Updates the Windows RunCommand log-upload script to use MSI auto-login environment variables and removes the explicit AzCopy login step.

Comment on lines +147 to 150
.\azcopy.exe login --login-type=MSI

Write-Log "Copying $URL to $Dest"
.\azcopy.exe copy "$URL" "$Dest"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

azcopy.exe is a native executable, so $ErrorActionPreference = "Stop" will not fail the script when azcopy login/azcopy copy returns a non-zero exit code. As written, a login/copy failure can be silently ignored and the VHD build may proceed with confusing downstream errors. Capture $LASTEXITCODE after these calls (and throw/log AzCopy logs on failure), or wrap them in a helper that enforces failure on non-zero exit codes.

Suggested change
.\azcopy.exe login --login-type=MSI
Write-Log "Copying $URL to $Dest"
.\azcopy.exe copy "$URL" "$Dest"
.\azcopy.exe login --login-type=MSI
$azcopyLoginExitCode = $LASTEXITCODE
if ($azcopyLoginExitCode -ne 0)
{
Write-Log "AzCopy login failed with exit code $azcopyLoginExitCode"
if (Test-Path -Path "$env:AZCOPY_LOG_LOCATION\*.log")
{
Write-Log "--- START AzCopy Log (on login failure)"
Get-Content "$env:AZCOPY_LOG_LOCATION\*.log" | Write-Log
Write-Log "--- END AzCopy Log (on login failure)"
}
throw "AzCopy login failed with exit code $azcopyLoginExitCode"
}
Write-Log "Copying $URL to $Dest"
.\azcopy.exe copy "$URL" "$Dest"
$azcopyCopyExitCode = $LASTEXITCODE
if ($azcopyCopyExitCode -ne 0)
{
Write-Log "AzCopy copy from $URL to $Dest failed with exit code $azcopyCopyExitCode"
if (Test-Path -Path "$env:AZCOPY_LOG_LOCATION\*.log")
{
Write-Log "--- START AzCopy Log (on copy failure)"
Get-Content "$env:AZCOPY_LOG_LOCATION\*.log" | Write-Log
Write-Log "--- END AzCopy Log (on copy failure)"
}
throw "AzCopy copy failed with exit code $azcopyCopyExitCode"
}

Copilot uses AI. Check for mistakes.
Comment on lines 616 to 625
Invoke-WebRequest -UseBasicParsing https://aka.ms/downloadazcopy-v10-windows -OutFile azcopy.zip
Expand-Archive azcopy.zip
cd .\azcopy\*
$env:AZCOPY_AUTO_LOGIN_TYPE = "AZCLI"
$env:AZCOPY_CONCURRENCY_VALUE = "AUTO"
$env:AZCOPY_AUTO_LOGIN_TYPE="MSI"
$env:AZCOPY_MSI_RESOURCE_STRING=$arg3
C:\k\debug\collect-windows-logs.ps1
$CollectedLogs=(Get-ChildItem . -Filter "*_logs.zip" -File)[0].Name
.\azcopy.exe login
.\azcopy.exe copy $CollectedLogs "$arg1/collected-node-logs.zip"
.\azcopy.exe copy "C:\azuredata\CustomDataSetupScript.log" "$arg1/cse.log"
.\azcopy.exe copy "C:\AzureData\provision.complete" "$arg1/provision.complete"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The RunCommand PowerShell script relies on azcopy.exe copy succeeding, but native exe failures won’t automatically stop the script unless you explicitly check $LASTEXITCODE/throw (or set up error handling that converts non-zero exit codes into terminating errors). Without that, log uploads can partially fail while the run command still returns success, making debugging flaky. Consider adding explicit exit-code checks after each AzCopy invocation so the test fails fast when uploads fail.

Copilot uses AI. Check for mistakes.
@awesomenix awesomenix merged commit f4322fe into main Mar 10, 2026
26 of 36 checks passed
@awesomenix awesomenix deleted the revert-8047-nishp/fix/azcopy_scripts branch March 10, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants