Install and Find AzCopy

This commit is contained in:
travis plunk
2022-02-17 12:40:53 -08:00
parent e3d9264257
commit d8175fc1e0
6 changed files with 66 additions and 6 deletions
+26
View File
@@ -3218,3 +3218,29 @@ function Set-CorrectLocale
# Output the locale to log it
locale
}
function Install-AzCopy {
$testPath = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
if (Test-Path $testPath) {
Write-Verbose "AzCopy already installed" -Verbose
return
}
$destination = "$env:TEMP\azcopy81.msi"
Invoke-WebRequest "https://aka.ms/downloadazcopy" -OutFile $destination
Start-Process -FilePath $destination -ArgumentList "/quiet" -Wait
}
function Find-AzCopy {
$searchPaths = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
foreach ($filter in $searchPaths) {
$azCopy = Get-ChildItem -Path $filter -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName -First 1
if ($azCopy) {
return $azCopy
}
}
$azCopy = Get-Command -Name azCopy -ErrorAction Stop | Select-Object -First 1
return $azCopy.Path
}
@@ -1,10 +1,19 @@
steps:
- checkout: self
clean: true
- download: none
- template: release-SetReleaseTagAndContainerName.yml
- pwsh: |
$azcopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
Install-AzCopy
displayName: Install AzCopy
- pwsh: |
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
$azcopy = Find-AzCopy
& $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:$(StorageAccountKey)
displayName: Download Azure Artifacts
@@ -65,10 +65,16 @@ jobs:
Write-Host "##$vstsCommandString"
displayName: Create MsixBundle
- pwsh: |
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
Install-AzCopy
displayName: Install AzCopy
- pwsh: |
## We use AzCopy v8.1 in our release pipeline, see the documentation at:
## https://docs.microsoft.com/en-us/previous-versions/azure/storage/storage-use-azcopy
$azcopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
$azcopy = Find-AzCopy
& $azcopy /Source:$(BundleDir) /Dest:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion)-private /DestKey:$(StorageAccountKey) /Pattern:*.msixbundle /Y
displayName: Upload MSIX Bundle package to Az Blob
@@ -15,7 +15,13 @@ steps:
displayName: Set Release Name
- pwsh: |
$azcopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
Install-AzCopy
displayName: Install AzCopy
- pwsh: |
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
$azcopy = Find-AzCopy
& $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:$(StorageAccountKey)
displayName: Download Azure Artifacts
@@ -12,7 +12,13 @@ steps:
displayName: Set Release Name
- pwsh: |
$azcopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
Install-AzCopy
displayName: Install AzCopy
- pwsh: |
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
$azcopy = Find-AzCopy
& $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:$(StorageAccountKey)
displayName: Download Azure Artifacts
@@ -8,7 +8,8 @@ jobs:
displayName: Build and Publish VPack - ${{ parameters.architecture }}
condition: succeeded()
pool: PowerShell1ES
pool:
name: PowerShell1ES
demands:
- ImageOverride -equals PSMMS2019-Secure
steps:
@@ -20,7 +21,13 @@ jobs:
ReleaseTagVar: $(ReleaseTagVar)
- pwsh: |
$azcopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
Install-AzCopy
displayName: Install AzCopy
- pwsh: |
Import-module '$(BUILD.SOURCESDIRECTORY)/build.psm1'
$azcopy = Find-AzCopy
Write-Host "running: $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:****** /Pattern:PowerShell-$(Version)-win-${{ parameters.architecture }}.zip /Z:$(AGENT.TEMPDIRECTORY)"
& $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:$(StorageAccountKey) /Pattern:PowerShell-$(Version)-win-${{ parameters.architecture }}.zip /Z:$(AGENT.TEMPDIRECTORY)