build: partially revert AzCopy changes from 22c509f (#19092)

When we first transitioned to the `R1` network isolation
environment--which required us to _not_ contact
powershellgallery.com--we had to give up on the `AzureFileCopy` task.

Since then, the `AzurePowerShell` task has also become somewhat broken
while OneBranch fixed the issue that prevented us from using
`AzureFileCopy`.

In short, we now need to:

- Install the Azure PowerShell modules directly from our own feed (which
satisfies the network constraint)
- ... using `PSResourceGet` ...
- ... for Windows PowerShell 5.1 ...
- which is used by `AzureFileCopy` to later perform authentication.
This commit is contained in:
Dustin L. Howett
2025-07-02 18:01:39 -05:00
committed by GitHub
parent a25d968fe0
commit 43b59d504b
2 changed files with 24 additions and 9 deletions

View File

@@ -78,7 +78,6 @@ autoscrolling
Autowrap
AVerify
awch
AZCOPY
azurecr
AZZ
backgrounded
@@ -1342,7 +1341,6 @@ PROPTITLE
propvar
propvariant
psa
PSCRED
PSECURITY
pseudoconsole
psh

View File

@@ -75,13 +75,30 @@ jobs:
}
displayName: "Wrangle Unpackaged builds into place, rename"
- task: AzurePowerShell@5
- task: PowerShell@2
displayName: Install Azure Modules from custom PowerShell Gallery Repo
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
pwsh: false # We are preparing modules for AzureFileCopy, which uses PowerShell 5.1
targetType: inline
script: |-
$MachineToken = $env:SYSTEM_ACCESSTOKEN | ConvertTo-SecureString -AsPlainText -Force
$Credential = [PSCredential]::new("ONEBRANCH_TOKEN", $MachineToken)
$MachineToken = $null
$Feed = "https://pkgs.dev.azure.com/shine-oss/terminal/_packaging/TerminalDependencies/nuget/v3/index.json"
Register-PSResourceRepository -Name "PSGalleryUpstream" -Uri $Feed -Trusted
Get-PSResourceRepository
Install-PSResource -Name Az.Accounts, Az.Storage, Az.Network, Az.Resources, Az.Compute -Repository "PSGalleryUpstream" -Credential $Credential
- task: AzureFileCopy@6
displayName: Publish to Storage Account
inputs:
sourcePath: _out/*
Destination: AzureBlob
azureSubscription: ${{ parameters.subscription }}
azurePowerShellVersion: LatestVersion
pwsh: true
ScriptType: InlineScript
Inline: |-
$Env:AZCOPY_AUTO_LOGIN_TYPE="PSCRED"
& AzCopy copy "_out\*" "https://${{ parameters.storageAccount }}.blob.core.windows.net/${{ parameters.storageContainer }}/" --content-type application/octet-stream
storage: ${{ parameters.storageAccount }}
ContainerName: ${{ parameters.storageContainer }}
AdditionalArgumentsForBlobCopy: "--content-type application/octet-stream"