Tag Archives: upload

Uploading your RemoteApp image directory from Azure to RemoteApp

If you’ve been working with RemoteApp for a while you’ve most likely gotten tired of downloading and uploading that image by now. Most of us have probably set up a VM in Azure and added a disk to it, just bouncing the VHD off of that one. Saves a lot of time just staying in Azure. But still, downloading it IS time consuming so to get around that I’ve written a script. Before you download it there are some pointers:

There is NO error checking. Meaning you must remember to disable EFS, install all the roles/features and run sysprep manually. If you forget something you’ll notice that when you try to start your image. That’s VERY late in the process.

The script needs you to have the Azure Storage SDK installed. Same here, if the path to the DLL has changed it’ll fail. If my calendar decides to clear out I’ll give it some time and clean it up but for now it’s a quick and dirty fix… Copy below, save as .ps1 and off you go!

# Load Assembly – Without this file, it’ll all fail…
Add-Type -Path “C:Program Files (x86)Microsoft SDKsAzurePowerShellServiceManagementAzureNetworkMicrosoft.WindowsAzure.Storage.dll”

# Source information
# Information from storage account
$sourceStorageAccount = “storageaccountname” # <- Storage account name
$sourceStorageKey     = “yourstoragekey” # <- The key to your storage account
$sourceContainer      = “vhd” # <- Container name
$sourceFilename       = “RemoteAppTemplate.vhd” <- VHD name, can be seen in your container
$sourceContainerUri   = [String]::Format(“https://{0}.blob.core.windows.net/{1}”, $sourceStorageAccount, $sourceContainer)

# Destination information
# Information from RemoteApp upload script commandline
$destStorageAccount = “cdvne195334804rdcm”    # <- Destination name
$destStorageSAS     = “?sv=2012-02-12&sr=b&si=f6939bb2-a99d-43b6-823a-fe8ad44f5c20&sig=6q%2Bk8t7xzzC7DeICrWvb39rh4lUEijg93UFL7631V6s%3D” # <- SAS key
$destContainer      = “goldimages” # <- Container name
$destFilename       = “f6939bb2-a88d-43b6-811a-fe8ad41f5c20.vhd” # <- VHD name, can be seen in the command line from RemoteApp
$destUri            = [String]::Format(“https://{0}.blob.core.windows.net/{1}/{2}”, $destStorageAccount, $destContainer, $destFilename)

# This is where the magic happens

Write-host “Uploading your image…”
$sourceCredentials = New-Object Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($sourceStorageAccount, $sourceStorageKey)
$sourceContainer = New-Object Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer($sourceContainerUri, $sourceCredentials)
$sourceBlob = $sourceContainer.GetBlobReferenceFromServer($sourceFilename)
$sourceStream = $sourceBlob.OpenRead()

$destCredentials = New-Object Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($destStorageSAS)
$destBlob = New-Object Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob($destUri, $destCredentials)
$destBlob.UploadFromStream($sourceStream)

$sourceStream.Close()
$destBlob.Metadata[“Status”] = “UploadComplete”
$destBlob.SetMetadata()

 

A good idea is to run this script from a VM in Azure too. That’ll speed up the process. Azcopy would be able to do the same thing if it supported SAS-usage across subscriptions.

Creating and uploading your Azure RemoteApp template image

Creating and uploading the image for RemoteApp turned out to be a challenge for some odd reasons. For the script Upload-AzureRemoteAppTemplateImage.ps1 to work you need to make sure you fulfill the prereqs it needs. Which can be found if you read the script 😉

If Upload-AzureRemoteAppTemplateImage.ps1 fails for “odd” reasons you need to make sure that you’re running PowerShell as Admin and that you’re starting “Windows Azure PowerShell” or have the Azure module loaded.

Here’s my short list of what you need to do:

  • Create a new Hyper-V VM with a 40 GB FIXED dynamic (now supported) size disk.
  • Install Windows Server 2012 R2 (only OS supported)
  • Install RDSH role and Desktop Experience feature (both needed)
  • Reboot (needed to make sure application installations are aware of RDS)
  • Login
  • Install the applications you want to publish to your users
  • From an elevated CMD, run “fsutil behavior set disableencryption 1” (disables EFS encryption of file system)
  • Reboot (makes sure EFS disable is written to registry)
  • Login
  • Run “sysprep /oobe /generalize /shutdown”

Once your machine is turned off you need to start PowerShell as administrator with the Azure cmdlets.

Run the script provided by the portal, find your VHD-file and you should be on your way!

Uploading the file

upload4

 

 

The portal states the template status as “uploading”

upload3