Skip to content

Commit

Permalink
Merge pull request microsoft#2889 from janegilring/azcopy_fix
Browse files Browse the repository at this point in the history
Temporarily moved azcopy installation
  • Loading branch information
janegilring authored Jan 10, 2025
2 parents ea763fd + 441ea14 commit adff04b
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
'Microsoft.Bicep',
'Kubernetes.kubectl',
'Microsoft.Edge',
'Microsoft.Azure.AZCopy.10',
#'Microsoft.Azure.AZCopy.10',
'Microsoft.VisualStudioCode',
'Microsoft.AzureDataStudio',
'Microsoft.VisualStudioCode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'Microsoft.Bicep',
'Kubernetes.kubectl',
'Microsoft.Edge',
'Microsoft.Azure.AZCopy.10',
#'Microsoft.Azure.AZCopy.10',
'Microsoft.AzureDataStudio',
'Microsoft.VisualStudioCode',
'Microsoft.SQLServerManagementStudio',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'Microsoft.Bicep',
'Kubernetes.kubectl',
'Microsoft.Edge',
'Microsoft.Azure.AZCopy.10',
#'Microsoft.Azure.AZCopy.10',
'Microsoft.VisualStudioCode',
'Microsoft.AzureDataStudio',
'Microsoft.VisualStudioCode',
Expand Down
1 change: 1 addition & 0 deletions azure_jumpstart_ag/artifacts/PowerShell/Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/tests/common.tests.p
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/tests/k8s.tests.ps1") -OutFile "$AgDirectory\tests\k8s.tests.ps1"
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/tests/Invoke-Test.ps1") -OutFile "$AgDirectory\tests\Invoke-Test.ps1"
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/tests/ag-bginfo.bgi") -OutFile "$AgDirectory\tests\ag-bginfo.bgi"
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/azcopy_install.ps1") -OutFile "$AgPowerShellDir\azcopy_install.ps1"

if($scenario -eq "contoso_supermarket"){
Invoke-WebRequest ($templateBaseUrl + "artifacts/settings/Bookmarks-contoso-supermarket") -OutFile "$AgToolsDir\Bookmarks"
Expand Down
4 changes: 4 additions & 0 deletions azure_jumpstart_ag/artifacts/PowerShell/Winget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $ErrorActionPreference = 'SilentlyContinue'
$AgDir = 'C:\Ag'
$AgLogsDir = "$AgDir\Logs"
$AgConfig = Import-PowerShellDataFile -Path $Env:AgConfigPath
$AgPowerShellDir = $AgConfig.AgDirectories["AgPowerShellDir"]

$logFilePath = Join-Path -Path $AgLogsDir -ChildPath ('WinGet-provisioning-' + (Get-Date -Format 'yyyyMMddHHmmss') + '.log')

Expand All @@ -20,6 +21,9 @@ $winget = Join-Path -Path $env:LOCALAPPDATA -ChildPath Microsoft\WindowsApps\win
# Windows Terminal needs to be installed per user, while WinGet Configuration runs as SYSTEM. Hence, this package is installed in the logon script.
& $winget install Microsoft.WindowsTerminal --version 1.18.3181.0 -s winget --silent --accept-package-agreements

# Temporary workaround for AzCopy installation due to CDN issues
& $AgPowerShellDir\azcopy_install.ps1

##############################################################
# Install Winget packages
##############################################################
Expand Down
48 changes: 48 additions & 0 deletions azure_jumpstart_ag/artifacts/PowerShell/azcopy_install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$azCopyUrl = "https://aka.ms/downloadazcopy-v10-windows"
$downloadPath = "$env:TEMP\azcopy.zip"
$destinationFolder = "C:\Program Files\AzCopy"


# Download the AzCopy zip file
Write-Host "Downloading AzCopy from $azCopyUrl..."
Invoke-WebRequest -Uri $azCopyUrl -OutFile $downloadPath -ErrorAction Stop
Write-Host "Download completed."

# Create the destination folder if it doesn't exist
if (-not (Test-Path -Path $destinationFolder)) {
Write-Host "Creating destination folder: $destinationFolder"
New-Item -ItemType Directory -Path $destinationFolder -Force
}

# Extract the AzCopy zip file
Write-Host "Extracting AzCopy to $destinationFolder..."
Expand-Archive -Path $downloadPath -DestinationPath $destinationFolder -Force
Write-Host "Extraction completed."

# Move the contents of the azcopy subfolder one level up
$subfolder = Get-ChildItem -Path $destinationFolder -Directory | Where-Object { $_.Name -match "azcopy_windows_amd64" }
if ($subfolder) {
Write-Host "Moving contents of $($subfolder.Name) one level up..."
Move-Item -Path "$($subfolder.FullName)\*" -Destination $destinationFolder -Force
Remove-Item -Path $subfolder.FullName -Recurse -Force
Write-Host "Contents moved successfully."
} else {
Write-Host "No subfolder matching 'azcopy_windows_amd64' found. Skipping move."
}

# Update the Path environment variable
Write-Host "Updating Path environment variable..."
$envPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
if (-not $envPath.Contains($destinationFolder)) {
[Environment]::SetEnvironmentVariable("Path", "$envPath;$destinationFolder", [System.EnvironmentVariableTarget]::Machine)
Write-Host "Path variable updated. Please restart PowerShell to reflect changes."
} else {
Write-Host "Path already contains $destinationFolder. No changes made."
}

# Clean up
Write-Host "Cleaning up temporary files..."
Remove-Item -Path $downloadPath -Force
Write-Host "Temporary files cleaned up."

Write-Host "AzCopy installation and setup completed."
1 change: 1 addition & 0 deletions azure_jumpstart_arcbox/artifacts/Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Invoke-WebRequest ($templateBaseUrl + "artifacts/tests/arcbox-bginfo.bgi") -OutF
Invoke-WebRequest ($templateBaseUrl + "artifacts/tests/common.tests.ps1") -OutFile $Env:ArcBoxTestsDir\common.tests.ps1
Invoke-WebRequest ($templateBaseUrl + "artifacts/tests/Invoke-Test.ps1") -OutFile $Env:ArcBoxTestsDir\Invoke-Test.ps1
Invoke-WebRequest ($templateBaseUrl + "artifacts/WinGet.ps1") -OutFile $Env:ArcBoxDir\WinGet.ps1
Invoke-WebRequest ($templateBaseUrl + "artifacts/azcopy_install.ps1") -OutFile $Env:ArcBoxDir\azcopy_install.ps1

# Workbook template
if ($flavor -eq "ITPro") {
Expand Down
3 changes: 3 additions & 0 deletions azure_jumpstart_arcbox/artifacts/WinGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ switch ($env:flavor) {
'ITPro' { & $winget configure --file C:\ArcBox\DSC\itpro.dsc.yml --accept-configuration-agreements --disable-interactivity }
}

# Temporary workaround for AzCopy installation due to CDN issues
& $Env:ArcBoxDir\azcopy_install.ps1

# Start remaining logon scripts
Get-ScheduledTask *LogonScript* | Start-ScheduledTask

Expand Down
48 changes: 48 additions & 0 deletions azure_jumpstart_arcbox/artifacts/azcopy_install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$azCopyUrl = "https://aka.ms/downloadazcopy-v10-windows"
$downloadPath = "$env:TEMP\azcopy.zip"
$destinationFolder = "C:\Program Files\AzCopy"


# Download the AzCopy zip file
Write-Host "Downloading AzCopy from $azCopyUrl..."
Invoke-WebRequest -Uri $azCopyUrl -OutFile $downloadPath -ErrorAction Stop
Write-Host "Download completed."

# Create the destination folder if it doesn't exist
if (-not (Test-Path -Path $destinationFolder)) {
Write-Host "Creating destination folder: $destinationFolder"
New-Item -ItemType Directory -Path $destinationFolder -Force
}

# Extract the AzCopy zip file
Write-Host "Extracting AzCopy to $destinationFolder..."
Expand-Archive -Path $downloadPath -DestinationPath $destinationFolder -Force
Write-Host "Extraction completed."

# Move the contents of the azcopy subfolder one level up
$subfolder = Get-ChildItem -Path $destinationFolder -Directory | Where-Object { $_.Name -match "azcopy_windows_amd64" }
if ($subfolder) {
Write-Host "Moving contents of $($subfolder.Name) one level up..."
Move-Item -Path "$($subfolder.FullName)\*" -Destination $destinationFolder -Force
Remove-Item -Path $subfolder.FullName -Recurse -Force
Write-Host "Contents moved successfully."
} else {
Write-Host "No subfolder matching 'azcopy_windows_amd64' found. Skipping move."
}

# Update the Path environment variable
Write-Host "Updating Path environment variable..."
$envPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
if (-not $envPath.Contains($destinationFolder)) {
[Environment]::SetEnvironmentVariable("Path", "$envPath;$destinationFolder", [System.EnvironmentVariableTarget]::Machine)
Write-Host "Path variable updated. Please restart PowerShell to reflect changes."
} else {
Write-Host "Path already contains $destinationFolder. No changes made."
}

# Clean up
Write-Host "Cleaning up temporary files..."
Remove-Item -Path $downloadPath -Force
Write-Host "Temporary files cleaned up."

Write-Host "AzCopy installation and setup completed."
14 changes: 7 additions & 7 deletions azure_jumpstart_arcbox/artifacts/dsc/common.dsc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ properties:
settings:
id: Microsoft.Edge
source: winget
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: azcopy
directives:
description: Install azcopy
settings:
id: Microsoft.Azure.AZCopy.10
source: winget
# - resource: Microsoft.WinGet.DSC/WinGetPackage
# id: azcopy
# directives:
# description: Install azcopy
# settings:
# id: Microsoft.Azure.AZCopy.10
# source: winget
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: DotNetSDK8
directives:
Expand Down
1 change: 1 addition & 0 deletions azure_jumpstart_hcibox/artifacts/PowerShell/Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Invoke-WebRequest ($templateBaseUrl + "artifacts/hci.parameters.json") -OutFile
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/dsc/packages.dsc.yml") -OutFile "$($HCIBoxConfig.Paths["DSCDir"])\packages.dsc.yml"
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/dsc/hyper-v.dsc.yml") -OutFile "$($HCIBoxConfig.Paths["DSCDir"])\hyper-v.dsc.yml"
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/WinGet.ps1") -OutFile "$HCIPath\WinGet.ps1"
Invoke-WebRequest ($templateBaseUrl + "artifacts/PowerShell/azcopy_install.ps1") -OutFile "$HCIPath\azcopy_install.ps1"

# Replace password and DNS placeholder
Write-Host "Updating config placeholders with injected values."
Expand Down
3 changes: 3 additions & 0 deletions azure_jumpstart_hcibox/artifacts/PowerShell/WinGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ $winget = Join-Path -Path $env:LOCALAPPDATA -ChildPath Microsoft\WindowsApps\win
# Windows Terminal needs to be installed per user, while WinGet Configuration runs as SYSTEM. Hence, this package is installed in the logon script.
& $winget install Microsoft.WindowsTerminal --version 1.18.3181.0 -s winget

# Temporary workaround for AzCopy installation due to CDN issues
& "$($Env:HCIBoxDir)\azcopy_install.ps1"

# Apply WinGet Configuration files
& $winget configure --file "$($Env:HCIBoxDir)\DSC\packages.dsc.yml" --accept-configuration-agreements --disable-interactivity
& $winget configure --file "$($Env:HCIBoxDir)\DSC\hyper-v.dsc.yml" --accept-configuration-agreements --disable-interactivity
Expand Down
48 changes: 48 additions & 0 deletions azure_jumpstart_hcibox/artifacts/PowerShell/azcopy_install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
$azCopyUrl = "https://aka.ms/downloadazcopy-v10-windows"
$downloadPath = "$env:TEMP\azcopy.zip"
$destinationFolder = "C:\Program Files\AzCopy"


# Download the AzCopy zip file
Write-Host "Downloading AzCopy from $azCopyUrl..."
Invoke-WebRequest -Uri $azCopyUrl -OutFile $downloadPath -ErrorAction Stop
Write-Host "Download completed."

# Create the destination folder if it doesn't exist
if (-not (Test-Path -Path $destinationFolder)) {
Write-Host "Creating destination folder: $destinationFolder"
New-Item -ItemType Directory -Path $destinationFolder -Force
}

# Extract the AzCopy zip file
Write-Host "Extracting AzCopy to $destinationFolder..."
Expand-Archive -Path $downloadPath -DestinationPath $destinationFolder -Force
Write-Host "Extraction completed."

# Move the contents of the azcopy subfolder one level up
$subfolder = Get-ChildItem -Path $destinationFolder -Directory | Where-Object { $_.Name -match "azcopy_windows_amd64" }
if ($subfolder) {
Write-Host "Moving contents of $($subfolder.Name) one level up..."
Move-Item -Path "$($subfolder.FullName)\*" -Destination $destinationFolder -Force
Remove-Item -Path $subfolder.FullName -Recurse -Force
Write-Host "Contents moved successfully."
} else {
Write-Host "No subfolder matching 'azcopy_windows_amd64' found. Skipping move."
}

# Update the Path environment variable
Write-Host "Updating Path environment variable..."
$envPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
if (-not $envPath.Contains($destinationFolder)) {
[Environment]::SetEnvironmentVariable("Path", "$envPath;$destinationFolder", [System.EnvironmentVariableTarget]::Machine)
Write-Host "Path variable updated. Please restart PowerShell to reflect changes."
} else {
Write-Host "Path already contains $destinationFolder. No changes made."
}

# Clean up
Write-Host "Cleaning up temporary files..."
Remove-Item -Path $downloadPath -Force
Write-Host "Temporary files cleaned up."

Write-Host "AzCopy installation and setup completed."
14 changes: 7 additions & 7 deletions azure_jumpstart_hcibox/artifacts/PowerShell/dsc/packages.dsc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ properties:
settings:
id: Microsoft.Edge
source: winget
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: azcopy
directives:
description: Install azcopy
settings:
id: Microsoft.Azure.AZCopy.10
source: winget
# - resource: Microsoft.WinGet.DSC/WinGetPackage
# id: azcopy
# directives:
# description: Install azcopy
# settings:
# id: Microsoft.Azure.AZCopy.10
# source: winget
- resource: Microsoft.WinGet.DSC/WinGetPackage
id: DotNetSDK8
directives:
Expand Down

0 comments on commit adff04b

Please sign in to comment.