Apps, Desktops, and Virtualization

Kyle Wise |Sharing my IT Experience

  • 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
  • VMware
  • 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

  • Auto-scale for Azure Files Storage Premium
  • Check Your Defender For Storage Plans When Using Azure Storage and FSLogix Profiles
  • Tag AVD Personal Desktops With Assigned User
  • Check if Azure Storage Account Keys are Older Than 180 Days
  • Compare and Delete AD Computer Accounts
  • Install Universal Print Driver and Map Printer

Categories

  • Citrix (100)
    • AppDisks (5)
    • AppDNA (3)
    • Citrix Receiver (11)
    • Director (8)
    • End User Experience (3)
    • HDX 3D Pro (4)
    • Licensing Server (4)
    • Netscaler (8)
    • Provisioning Services (14)
    • StoreFront (7)
    • WEM (1)
    • XenApp (16)
    • XenDesktop (26)
  • Microsoft (41)
    • App-V (1)
    • Azure (14)
    • Azure Virtual Desktops (19)
    • Defender For Cloud (1)
    • Group Policy (3)
    • Microsoft Office 2010 (2)
    • Microsoft Office 2013 (1)
    • Microsoft Operations Management Suite (1)
    • OMS (1)
    • Remote Desktop (1)
    • SCOM (1)
    • SQL Server (2)
  • Troubleshooting (1)
    • Adobe (1)
  • VMware (1)
    • App Volumes (1)

Websites

  • GitHub Repos

Tags

Adobe App-V AppDisks AppDNA App Volumes Azure Azure Virtual Desktops Citrix Citrix Receiver Defender For Cloud Director End User Experience Group Policy HDX 3D Pro Licensing Server Microsoft Microsoft Office 2010 Microsoft Office 2013 Microsoft Operations Management Suite Netscaler OMS Provisioning Services Remote Desktop SCOM SQL Server StoreFront Troubleshooting VMware WEM XenApp XenDesktop

Archives

  • 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 © 2023 Apps, Desktops, and Virtualization | Theme by: Theme Horse | Powered by: WordPress