Apps, Desktops, and Virtualization

  • Home
  • Microsoft
    • Azure Virtual Desktops
    • App-V
    • Azure
    • Group Policy
    • Remote Desktop
    • Troubleshooting
      • Adobe
    • Office 365
      • Microsoft Office 2013
      • Microsoft Office 2010
    • System Center
      • SCCM
      • SCOM
  • Citrix
    • AppDisks
    • AppDNA
    • End User Experience
    • Director
    • XenDesktop
    • XenApp
    • StoreFront
    • Provisioning Services
    • Netscaler
    • Citrix Receiver
    • Workspace
    • Licensing Server
  • About

Replicate AVD MSIX App Attach Files to Storage Account Shares in Different Regions

Azure Virtual Desktops, Microsoft

Replicate AVD MSIX App Attach Files to Storage Account Shares in Different Regions

Kyle Wise
July 29, 2023
No Comments

If you have AVD Host Pools in multiple regions and you are using App Attach you will want to replicate your packages to a Azure Storage account in the same region. Here’s a script that will copy your MSIX App Attach files from your Primary/Source Storage Account to other Storage Accounts.

This uses AZCopy, KeyVault and can be used with GitHub Actions to automatically run.

#Add Check for Available Space
#Todo: If less than 10GB, add space.
# Download and extract AzCopy for Linux. You can change this to Windows AZCopy if you want.

              $azCopyDownloadURL = "https://aka.ms/downloadazcopy-v10-linux"
              $downloadLocation = "$env:RUNNER_TEMP/AzCopy.tar.gz"
              $extractLocation = "$env:RUNNER_TEMP/AzCopy"
              $azCopyPath = "${extractLocation}/azcopy_linux_amd64_10.19.0/azcopy"
              # Check if AzCopy exists
              if (-not (Test-Path $azCopyPath)) {
                  Write-Output "AzCopy not found at $azCopyPath. Downloading and extracting..."
                  # Download AzCopy
                  Invoke-WebRequest -Uri $azCopyDownloadURL -OutFile $downloadLocation
                  # Ensure the extraction directory exists
                  New-Item -ItemType Directory -Force -Path $extractLocation
                  # Extract AzCopy
                  Invoke-Expression "tar -xzvf $downloadLocation -C $extractLocation"
                  # Make AzCopy executable
                  Invoke-Expression "chmod +x $azCopyPath"
                  if (-not (Test-Path $azCopyPath)) {
                  Write-Output "Failed to download or extract AzCopy. Exiting."
                  Exit
                  }
              }           
#Gets SAS from KeyVault.
try {
$cmsixsas = Get-AzKeyVaultSecret -VaultName "KEYVAULT" -Name "cmsixsas" -AsPlainText
$wmsixsas = Get-AzKeyVaultSecret -VaultName "KEYVAULT" -Name "wmsixsas" -AsPlainText
$emsixsas = Get-AzKeyVaultSecret -VaultName "KEYVAULT" -Name "emsixsas" -AsPlainText
$w2msixsas = Get-AzKeyVaultSecret -VaultName "KEYVAULT" -Name "w2msixsas" -AsPlainText
              }
              catch {
                  Write-Error "Error retrieving secrets from KeyVault: $_"
                  exit 1
              }
              # Define the source and destinations
              $sourceShare = "https://source.file.core.windows.net/apps"
              $destinations = @(
                  "https://dest1.file.core.windows.net/apps",
                  "https://dest2.file.core.windows.net/apps",
                  "https://dest3.file.core.windows.net/apps"
              )
              # For demonstration, we assume the source SAS token is the one for 'w2msix' since the URL matches.
              $sourceSASToken = $w2msixsas
              foreach ($destination in $destinations) {
                  # Find the corresponding SAS token for the destination
                  switch -regex ($destination) {
                      "cmsix" { $destSASToken = $cmsixsas }
                      "emsix" { $destSASToken = $emsixsas }
                      "wmsix" { $destSASToken = $wmsixsas }
                  }

# Construct the source and destination URLs with their respective SAS tokens
                  $sourceURL = "${sourceShare}${sourceSASToken}"
                  $destinationURL = "${destination}${destSASToken}"
                  Write-Output "Copying from $sourceURL to $destinationURL"
                  # Use AzCopy to copy with overwrite
                  & $azCopyPath copy $sourceURL $destinationURL --recursive=true --overwrite=false
                  # Check the exit code of AzCopy
                  if ($LASTEXITCODE -ne 0) {
                      Write-Error "AzCopy failed for source $sourceURL to destination $destinationURL"
                      exit 1
                  }
              }
              Write-Output "Copy operations completed."
Share or Save this:
Share
MSIX, Replication, Storage Account
  • ← Send AVD Host Pool Session Load Info to Teams
  • Delete AVD Multi-Session Hosts Running Old Image →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search Site

Recent

  • Automating FSLogix Profile Storage Alerts with Azure Logic Apps
  • Using Event Grid and Function App to Change VM Size when Capacity or Zone Allocation Issues Occur with Azure Virtual Machines or AVD.
  • Find Azure Virtual Desktop User Session
  • Azure Virtual Desktop Scaling Plan Check and Enable
  • Autoscaling Storage Account File Share Size
  • Get AVD Client Version, Latest Version and Delta Between Versions

Categories

  • Citrix (100)
    • AppDisks (5)
    • Citrix Receiver (11)
    • Director (8)
    • End User Experience (2)
    • HDX 3D Pro (4)
    • Licensing Server (4)
    • Netscaler (8)
    • Provisioning Services (14)
    • StoreFront (7)
    • XenApp (16)
    • XenDesktop (26)
  • FSLogix Office 365 (1)
  • Microsoft (55)
    • Azure (25)
    • Azure Virtual Desktops (34)
    • Defender For Cloud (2)
    • Eventgrid (1)
    • Group Policy (3)
    • LogicApp (1)
    • SQL Server (2)
  • VMware (1)

Websites

  • GitHub Repos

Tags

AppDisks Azure Azure Virtual Desktops Citrix Citrix Receiver Defender For Cloud Director End User Experience Eventgrid FSLogix Office 365 Group Policy HDX 3D Pro Licensing Server LogicApp Microsoft Netscaler Provisioning Services SQL Server StoreFront VMware XenApp XenDesktop

Archives

  • June 2025
  • June 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • March 2023
  • February 2023
  • October 2021
  • February 2020
  • August 2018
  • May 2017
  • November 2016
  • August 2016
  • July 2016
  • June 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • Phoenix, AZ
Copyright © 2025 Apps, Desktops, and Virtualization | Theme by: Theme Horse | Powered by: WordPress