I have clients that will be using a single multisession host is a host pool as they have more than one user with the host joined to AAD only. They will need to have additional storage added to the host for their data as we do not want it to reside on the OS partition. The ability to add managed disks to a host in this scenario in NMM would be greatly appreciated as at the moment I need to go into the Azure Portal to do so and I do not want all my technicians going into the Azure Portal.
Yes, I realize this mean the host is no longer disposable, but I have created workflows to ensure that someone cannot accidently re-image the device.
Ability to add managed disks to Host in Host Pool
I don't see this being a thing for every customer, but still a great idea!
Until this feature is added, could you possibly have the managed disk(s), that exist outside of the host, and be attached (after a reimage) with an Azure Runbook scripted action?
I was going to say what Dave said. Setting up an automation to attach and detach the managed disk could be viable.
To this end though, why not simply use a mapped drive from a file server or better, azure files?
These are Azure AD joined devices with no other Authentication service. The companies still need permissions applied to folders on the drive so that people only see what they are supposed to see. Adding a server or Azure Files would add an expense the client would not agree to and since you have to attach Azure Files as the storage account, I don't believe that I can set permissions on the Azure files using Azure AD only.
In our case these will also be few and far between as the affected clients are legacy clients we had to move from our old system. We have no plans in the future to deploy for clients this small. I'm talking 2 to 4 users max here.
Is there a pre-coded runbook somewhere that would do as Dave suggested?
Robert Reid I asked my favorite code creator (ChatGPT 🤣) and it came up with this:
(I haven't tested it, but it looks like it should work.)
Attach a Virtual Disk:
# Define variables
$resourceGroupName = "YourResourceGroup"
$vmName = "YourVMName"
$existingDiskName = "YourExistingDiskName"
$lun = 1 # Specify the logical unit number (LUN) for the disk
# Get the VM
$vm = Get-AzVM -ResourceGroupName $resourceGroupName -Name $vmName
# Get the existing managed disk
$existingDisk = Get-AzDisk -ResourceGroupName $resourceGroupName -DiskName $existingDiskName
# Attach the existing disk to the VM
$vm = Add-AzVMDataDisk `
-VM $vm `
-Name $existingDiskName `
-CreateOption Attach `
-ManagedDiskId $existingDisk.Id `
-Lun $lun
# Update the VM configuration
Update-AzVM -ResourceGroupName $resourceGroupName -VM $vm
Write-Output "Existing data disk attached successfully."
Detach a Virtual Disk:
# Define variables
$resourceGroupName = "YourResourceGroup"
$vmName = "YourVMName"
$existingDiskName = "YourExistingDiskName"
# Get the VM
$vm = Get-AzVM -ResourceGroupName $resourceGroupName -Name $vmName
# Find the disk to detach
$diskToRemove = $vm.StorageProfile.DataDisks | Where-Object { $_.Name -eq $existingDiskName }
# Check if the disk is attached
if ($diskToRemove -eq $null) {
Write-Output "The specified disk is not attached to the VM."
} else {
# Remove the disk from the VM configuration
$vm.StorageProfile.DataDisks = $vm.StorageProfile.DataDisks | Where-Object { $_.Name -ne $existingDiskName }
# Update the VM configuration
Update-AzVM -ResourceGroupName $resourceGroupName -VM $vm
Write-Output "Existing data disk detached successfully."
}
Please sign in to leave a comment.
Comments (4 comments)