MultiCloud Classroom notes 18/Sep/2026

create azure disk and mount to windows server

  • create a disk with type and size
  • create windows server / desktop

let create windows server and disk

terraform

resource "azurerm_managed_disk" "example" {
  name                 = "acctestmd"
  location             = azurerm_resource_group.example.location
  resource_group_name  = azurerm_resource_group.example.name
  storage_account_type = "Standard_LRS"
  create_option        = "Empty"
  disk_size_gb         = "5"

  tags = {
    environment = "staging"
  }
}


resource "azurerm_virtual_machine" "main" {
  name                  = "${var.prefix}-vm"
  location              = azurerm_resource_group.example.location
  resource_group_name   = azurerm_resource_group.example.name
  network_interface_ids = [azurerm_network_interface.main.id]
  vm_size               = "Standard_DS1_v2"

  # Uncomment this line to delete the OS disk automatically when deleting the VM
  # delete_os_disk_on_termination = true

  # Uncomment this line to delete the data disks automatically when deleting the VM
  # delete_data_disks_on_termination = true

  storage_image_reference {
    publisher = "Canonical"
    offer     = "0001-com-ubuntu-server-jammy"
    sku       = "22_04-lts"
    version   = "latest"
  }
  storage_os_disk {
    name              = "myosdisk1"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
  }
  managed_disk_id = azurerm_managed_disk.example.id
  os_profile {
    computer_name  = "hostname"
    admin_username = "testadmin"
    admin_password = "Password1234!"
  }
  os_profile_linux_config {
    disable_password_authentication = false
  }
  tags = {
    environment = "staging"
  }
}

resource "azurerm_virtual_machine_data_disk_attachment" "example" {
  managed_disk_id    = azurerm_managed_disk.example.id
  virtual_machine_id = azurerm_linux_virtual_machine.example.id
  lun                = "10"
  caching            = "ReadWrite"
}

az disk create --name windows --resource-group demo --size-gb 10 --sku StandardSSD_LRS

## out put
{
  "creationData": {
    "createOption": "Empty"
  },
  "diskIOPSReadWrite": 500,
  "diskMBpsReadWrite": 100,
  "diskSizeBytes": 10737418240,
  "diskSizeGB": 10,
  "diskState": "Unattached",
  "encryption": {
    "type": "EncryptionAtRestWithPlatformKey"
  },
  "id": "/subscriptions/ce2e62f0-7f43-4675-98f5-0735bedf76c9/resourceGroups/demo/providers/Microsoft.Compute/disks/windows",
  "location": "centralus",
  "name": "windows",
  "networkAccessPolicy": "AllowAll",
  "provisioningState": "Succeeded",
  "publicNetworkAccess": "Enabled",
  "resourceGroup": "demo",
  "sku": {
    "name": "StandardSSD_LRS",
    "tier": "Standard"
  },
  "tags": {},
  "timeCreated": "2026-09-18T02:05:15.2992854+00:00",
  "type": "Microsoft.Compute/disks",
  "uniqueId": "5a09cef8-478b-46f6-b0bb-bd36a428bcb1"
}
az vm disk attach -g MyResourceGroup --vm-name MyVm --name disk_name --new

steps to mount disk in powershell

  1. get disk list : Get-Disks
  2. bring disk online Set-Disk -Number 1 -IsOffline $false
  3. Initialize Disk: Initialize-Disk -Number 1 -PartitionStyle GPT
  4. create new partition New-Partition -DiskNumber 1 -DriveLetter F -UseMaximumSize
  5. Format disk: Format-Volume -DriveLetter F -FileSystem NTFS -NewFileSystemLabel "DataDrive"

Refer UI

powershell scrpit

# PowerShell Script: Initialize and Format Multiple Disks
# Author: Ram
# Purpose: Automate disk setup for Windows userdata

# Define list of disks and drive letters
$DiskList = @(
    @{ Number = 1; Letter = "F" },
    @{ Number = 2; Letter = "G" },
    @{ Number = 3; Letter = "H" }
)

# Loop through each disk entry
foreach ($disk in $DiskList) {
    $DiskNumber = $disk.Number
    $DriveLetter = $disk.Letter

    Write-Host "Processing Disk $DiskNumber -> Drive $DriveLetter"

    # 1. Bring disk online
    Set-Disk -Number $DiskNumber -IsOffline $false

    # 2. Initialize disk with GPT partition style
    Initialize-Disk -Number $DiskNumber -PartitionStyle GPT -ErrorAction SilentlyContinue

    # 3. Create new partition using maximum size and assign drive letter
    New-Partition -DiskNumber $DiskNumber -DriveLetter $DriveLetter -UseMaximumSize

    # 4. Format the partition with NTFS and label it "DataDriveX"
    $Label = "DataDrive$DiskNumber"
    Format-Volume -DriveLetter $DriveLetter -FileSystem NTFS -NewFileSystemLabel $Label -Confirm:$false
}

aws

  • console
  • cli
  • terraform
  • cloudformation

azure

  • portal
  • cli
  • terraform
  • arm/bicep
  • powershell

Install az module in windows server

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

login azure account

Connect-AzAccount
Get-AzResourceGroup

Refer here for azure modules.

Task:

  1. class recording and create new windows vm and attach new disk (5GB)
  2. setup az module and try connect azure account and check connection by get list resource group.

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%