How to Create Azure Shared Disks?

How to Create Azure Shared Disks?

Azure Shared Disks allow multiple virtual machines to share a single disk, enabling scenarios like clustering and shared data volumes in a High Availability (HA) environment. In this blog post, we will explore how to create Azure Shared Disks using both the Azure Portal and Azure CLI.

Prerequisites

Before we proceed with creating Azure Shared Disks, ensure you have the following prerequisites:

  1. An active Microsoft Azure account with appropriate permissions to create resources.
  2. At least two Azure Virtual Machines in the same region that will share the disk.

Step-by-Step Guide

Let’s dive into the process of creating Azure Shared Disks using both the Azure Portal and Azure CLI:

Step 1: Create a Managed Disk (Azure Portal)

  1. Log in to the Azure Portal (https://portal.azure.com/) using your Azure account.
  2. In the left-hand navigation pane, click on “Create a resource.”
  3. Search for “Managed Disk” and click on “Managed Disk.”
  4. Click on “Create” to start creating the Managed Disk.
  5. In the “Basics” tab, choose the subscription and resource group where you want to create the Managed Disk.
  6. Provide a unique name for the Managed Disk.
  7. Choose the region where the Managed Disk should be located.
  8. Configure additional settings like the disk size, caching preference, and encryption settings.
  9. Click “Next: Tags” to add any relevant tags or proceed to the next tab.
  10. Review the configuration and click “Review + create.”
  11. Finally, click “Create” to create the Azure Managed Disk.

Step 1: Create a Managed Disk (Azure CLI)

  1. Open a terminal or command prompt.
  2. Use the following command to create a Managed Disk:

Replace <disk-name>, <resource-group-name>, <region>, and <disk-size> with the appropriate values.

Step 2: Enable Shared Disks on the Managed Disk (Azure Portal)

  1. In the Azure Portal, navigate to the Managed Disk you created.
  2. Under “Settings,” click on “Configuration.”
  3. In the “Configuration” blade, set “Enable shared disks” to “Yes.”
  4. Click “Save” to apply the configuration and enable shared disks on the Managed Disk.

Step 2: Enable Shared Disks on the Managed Disk (Azure CLI)

  1. Open a terminal or command prompt.
  2. Use the following command to enable shared disks on the Managed Disk:

Replace <disk-name> and <resource-group-name> with the appropriate values.

Step 3: Attach the Shared Disk to Virtual Machines (Azure Portal)

  1. In the Azure Portal, navigate to the Managed Disk you created.
  2. Under “Settings,” click on “Access control (IAM).”
  3. Click on “Add” to add role assignment for the virtual machines.
  4. In the “Add role assignment” blade, select the appropriate role (e.g., “Contributor”) and search for the virtual machines that will access the Shared Disk.
  5. Click “Save” to add the role assignment.

Step 3: Attach the Shared Disk to Virtual Machines (Azure CLI)

  1. Open a terminal or command prompt.
  2. Use the following command to attach the Shared Disk to the virtual machines:

Replace <vm-name>, <resource-group-name>, and <disk-name> with the appropriate values.

  1. Repeat the above command for each virtual machine that needs access to the Shared Disk.

Conclusion

Azure Shared Disks enable the sharing of a single disk across multiple virtual machines, facilitating scenarios like clustering and shared data volumes. By following the step-by-step guide in this blog post, you can easily create Azure Shared Disks using both the Azure Portal and Azure CLI. Leverage the power of Shared Disks to build High Availability environments and optimize resource utilization in Microsoft Azure.