Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

Image deployment mixes drive letters

$
0
0

Hello,

I have a solution from a big vendor that deploys it's vms using drive letter C: for OS and F: for data. In the Azure Portal this means that the data disk is attached to Lun 1. After creating an image of the generalized vm and redeploying it the portal shows that data is still connected to Lun 1 but Windows now attaches the data disk to E: which leads to prgramms not working.

How can I ensure that the drive letter remain the same when deploying images?

The image is created through the Azure portal. Deployment happens for some reasons via PowerShell Runbook using this snippet:

$image = Get-AzureRMImage -ImageName $imageName -ResourceGroupName $rgImage
Get-AzureRmResourceGroup -Name $rgVm -ErrorVariable notPresent -ErrorAction SilentlyContinue
if ($notPresent)
{
    # ResourceGroup doesn't exist
    New-AzureRmResourceGroup -Name $rgVm -Location $location
}

$nsgRuleRDP = New-AzureRmNetworkSecurityRuleConfig -Name AllowRDP -Protocol Tcp -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $rgVm -Location $location -Name $vmNamePrefix-nsg -SecurityRules $nsgRuleRDP

for ($i=1; $i -le $vmNumber; $i++) {
	$vnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgVnet
	$pip = New-AzureRmPublicIpAddress -ResourceGroupName $rgVm -Location $location -AllocationMethod Dynamic -Name $vmNamePrefix-$i-pip
	$nic = New-AzureRmNetworkInterface -ResourceGroupName $rgVm -Location $location -Name $vmNamePrefix-$i-nic -SubnetId $vnet.Subnets[0].Id -Tag @{belongsToVm="$vmNamePrefix-$i";} -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $(Get-AzureRmNetworkSecurityGroup -Name $vmNamePrefix-nsg -ResourceGroupName $rgVm).Id
	$vm = New-AzureRmVMConfig -VMName $vmNamePrefix-$i -VMSize $vmSize
	$vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName $vmNamePrefix-$i -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate
	$vm = Set-AzureRmVMSourceImage -VM $vm -Id $image.Id
	$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
	New-AzureRmVM -ResourceGroupName $rgVm -Location $location -VM $vm -AsJob
}


Viewing all articles
Browse latest Browse all 12545


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>