Azure attach a new disk
To attach a new disk to an Azure virtual machine, you can follow these steps:
Using the Azure Portal:
- Log in to the Azure portal (https://portal.azure.com/).
- Navigate to your virtual machine by searching for it in the search bar or by browsing to the "Virtual machines" section.
- Click on the virtual machine to open its overview page.
- Click on "Disks" in the left-hand menu.
- Click on "Attach a new disk" at the top of the page.
- Select the type of disk you want to attach (e.g., Standard SSD, Premium SSD, etc.).
- Choose the size of the disk (in GB).
- Select the disk type (e.g., OS, Data, etc.).
- Click "Create" to create the new disk.
- Once the disk is created, click "Attach" to attach it to your virtual machine.
Using Azure CLI:
-
Install the Azure CLI (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest).
-
Run the following command to create a new disk:
az disk create --resource-group <resource-group-name> --name <disk-name> --size-gb <disk-size> --sku Standard_LRS
Replace
<resource-group-name>
with the name of your resource group,<disk-name>
with the name you want to give your disk, and<disk-size>
with the size of the disk in GB. -
Run the following command to attach the new disk to your virtual machine:
az vm disk attach --resource-group <resource-group-name> --name <vm-name> --disk <disk-name>
Replace
<resource-group-name>
with the name of your resource group,<vm-name>
with the name of your virtual machine, and<disk-name>
with the name of the disk you created.
Using PowerShell:
-
Install the Azure PowerShell module (https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azureps-4.8.0).
-
Run the following command to create a new disk:
New-AzDisk -ResourceGroupName <resource-group-name> -DiskName <disk-name> -DiskSizeGB <disk-size> -DiskType Standard_LRS
Replace
<resource-group-name>
with the name of your resource group,<disk-name>
with the name you want to give your disk, and<disk-size>
with the size of the disk in GB. -
Run the following command to attach the new disk to your virtual machine:
Add-AzVMDataDisk -ResourceGroupName <resource-group-name> -VMName <vm-name> -Name <disk-name>
Replace
<resource-group-name>
with the name of your resource group,<vm-name>
with the name of your virtual machine, and<disk-name>
with the name of the disk you created.
Note: Make sure you have the necessary permissions and credentials to create and attach disks to your Azure virtual machine.