Azure

Including Knowledge Disk To Azure VM Utilizing PowerShell

This text is a hands-on on tips on how to add information disk utilizing Powershell on Azure digital machine and please bear in mind that is a further useful resource and also you may need to pay for it. I’ve already defined tips on how to create and fasten information disks utilizing the Azure portal right here on this article. So on this article, we’re going to strive one other and easy method to do it.

So at first allow us to create and initialize some variables that we are going to use for creating information disk.

So first is the useful resource group and my useful resource group identify is anish-grp so this variable holds the anish-grp.

  1. $resourcegroup = ‘anish-grp’  

This variable holds the placement of the machine. So at the moment demovm is within the East US location so I’ve given my location as East US.

  1. $location = ‘East US’  

The following one is the disk kind and I am including a regular disk. So this variable holds the disk kind. I’m utilizing a regular disk due to pricing components.

  1. $storageType = ‘Standard_LRS’  

The following one is the diskname that we wish to be created. This variable holds the diskname that’s demodatadisk and the subsequent one holds the dimensions of the disk.

  1. $dataDiskName = ‘demodatadisk’  

So after initializing the disks, now we have to execute some extra instructions to create the info disk. So let’s execute the subsequent command.

 

So now we have to create a brand new disk configuration and beneath is the command to do this and we’re utilizing the variables now we have initialized.

  1. $datadiskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB $dataDiskSize  

After creating the configuration now are we’re going to create a brand new disk.

  1. $dataDisk01 = New-AzDisk -DiskName $dataDiskName -Disk   

Now we have to get a reference of a digital machine on which we’re going to connect the disk. So we’ll get a reference to the digital machine and that’s demovm.

  1. $datadiskConfig -ResourceGroupName $resourcegroup  

Now we’re going to add an information disk to the digital machine and beneath is the command for that. I’ve assing LUN to 1 as a result of after I created the info disk and connected the disk on this article, the LUN was zero for this disk it will be 1.

  1. $vm = Add-AzVMDataDisk -VM $vm -Title $dataDiskName -CreateOption Connect -ManagedDiskId $dataDisk01.Id -Lun 1  

After this command, we have to replace the digital machine, and beneath is the command to do this. So allow us to replace the digital machine.

  1. Replace-AzVM -VM $vm -ResourceGroupName $resourcegroup  

Now, should you go to all sources and verify for the disk, you will need to discover the newly created disk there. 

 

If you wish to study extra then please take a look at this documentation

 

On this article, we noticed tips on how to create and fasten information disks to Azure digital machine utilizing PowerShell and the way simple it’s.

 

Thanks for studying.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button