Azure attach a new disk

To attach a new disk to an Azure virtual machine, you can follow these steps:

Using the Azure Portal:

  1. Log in to the Azure portal (https://portal.azure.com/).
  2. Navigate to your virtual machine by searching for it in the search bar or by browsing to the "Virtual machines" section.
  3. Click on the virtual machine to open its overview page.
  4. Click on "Disks" in the left-hand menu.
  5. Click on "Attach a new disk" at the top of the page.
  6. Select the type of disk you want to attach (e.g., Standard SSD, Premium SSD, etc.).
  7. Choose the size of the disk (in GB).
  8. Select the disk type (e.g., OS, Data, etc.).
  9. Click "Create" to create the new disk.
  10. Once the disk is created, click "Attach" to attach it to your virtual machine.

Using Azure CLI:

  1. Install the Azure CLI (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest).

  2. 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.

  3. 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:

  1. Install the Azure PowerShell module (https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azureps-4.8.0).

  2. 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.

  3. 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.