fix: revert use azcli login for azcopy in windows#8050
Conversation
This reverts commit 97d6e46.
There was a problem hiding this comment.
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 loginwith--login-type=MSI. - Windows e2e log upload: switch AzCopy auto-login to MSI and remove the explicit
azcopy logincall.
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. |
| .\azcopy.exe login --login-type=MSI | ||
|
|
||
| Write-Log "Copying $URL to $Dest" | ||
| .\azcopy.exe copy "$URL" "$Dest" |
There was a problem hiding this comment.
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.
| .\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" | |
| } |
| 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" |
There was a problem hiding this comment.
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.
Reverts #8047