Dynamically mount FSLogix drive and set VHDLocations

51 Views Asked by At

I'm currently trying to use a local group policy script at logon of the user to mount a new drive (F:) where the FSLogix account of the user is stored. I don't know if this is even possible or what my options are.

The reason I do this is because I'm trying to implement a one-click deployment of an Azure Virtual Desktop setup and want to store the test user data in an Azure File Share and showcase the use of FSLogix accounts. I need some kind of way to first link the Azure file share to the VM and set the FSLogix registry settings to that file share and after that load the FSLogix user account.

Does someone have experience or ideas on how this can best be done?

1

There are 1 best solutions below

0
Arko On BEST ANSWER

For setting up FSLogix with Azure Files for Azure Virtual Desktop. You can follow the steps below-

Prerequisites

  • Azure subscription with permissions to create resources.
  • Azure Virtual Desktop environment set up.
  • Azure Files share created for FSLogix profiles.
  • FSLogix agent installed on AVD VMs.

create a new storage account if you haven’t.

az storage account create --name <YourStorageAccountName> --resource-group <YourResourceGroupName> --location <Location> --sku Standard_ZRS --kind StorageV2

enter image description here

Create the file share

az storage share create --name <YourFileShareName> --account-name <YourStorageAccountName>

enter image description here

Get storage account key

$storageKey = az storage account keys list --resource-group <YourResourceGroupName> --account-name <YourStorageAccountName> --query "[0].value" --output tsv

enter image description here

Assign appropriate permissions to the Azure File Share for your AD domain service.

In your AVD host pool, create a logon script to mount the file share when the user logs in.

$storageAccountName = "<YourStorageAccountName>"
$fileShareName = "<YourFileShareName>"
$driveLetter = "F"
$storageKey = "<YourStorageKey>"

#Mapping the drive
New-PSDrive -Name $driveLetter -PSProvider FileSystem -Root "\\$storageAccountName.file.core.windows.net\$fileShareName" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("Azure\$storageAccountName", (ConvertTo-SecureString $storageKey -AsPlainText -Force)))

enter image description here

Configure FSLogix via PowerShell i.e. on the AVD VMs, set the FSLogix registry keys.

$regPath = "HKLM:\SOFTWARE\FSLogix\Profiles"
$fileSharePath = "\\$storageAccountName.file.core.windows.net\$fileShareName"

# Ensure the registry path exists
if (-not (Test-Path $regPath)) {
    New-Item -Path $regPath -Force
}

# Configure the VHDLocations registry key
Set-ItemProperty -Path $regPath -Name "VHDLocations" -Value $fileSharePath

# Enable FSLogix Profile Containers
Set-ItemProperty -Path $regPath -Name "Enabled" -Value 1

enter image description here

Done. You can now log in to your AVD session and ensure that the F: drive is mounted and points to your Azure File Share.

References: