0% found this document useful (0 votes)
55 views2 pages

Azure Disk CMD

The document demonstrates how to create Azure resources like resource groups and managed disks using both PowerShell and Bash. It shows how to create a resource group, empty managed disk, update the disk size and sku, and then delete the resource group. Both PowerShell and Bash commands are provided to create, modify, and delete these Azure resources through the Azure CLI.

Uploaded by

sractive
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views2 pages

Azure Disk CMD

The document demonstrates how to create Azure resources like resource groups and managed disks using both PowerShell and Bash. It shows how to create a resource group, empty managed disk, update the disk size and sku, and then delete the resource group. Both PowerShell and Bash commands are provided to create, modify, and delete these Azure resources through the Azure CLI.

Uploaded by

sractive
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

_ eastus

PowerShell

$location = (Get-AzResourceGroup -Name az104-03b-rg1).Location

$rgName = 'az104-03c-rg1'

New-AzResourceGroup -Name $rgName -Location $location


Get-AzResourceGroup -Name $rgName

/subscriptions/8e71d731-f0df-44c2-abf3-563d6a24c159/resourceGroups/az104-03c-rg1

$diskConfig = New-AzDiskConfig `
-Location $location `
-CreateOption Empty `
-DiskSizeGB 32 `
-Sku Standard_LRS

$diskName = 'az104-03c-disk1'

New-AzDisk `
-ResourceGroupName $rgName `
-DiskName $diskName `
-Disk $diskConfig
Get-AzDisk -ResourceGroupName $rgName -Name $diskName

New-AzDiskUpdateConfig -DiskSizeGB 64 | Update-AzDisk -ResourceGroupName $rgName


-DiskName $diskName
Get-AzDisk -ResourceGroupName $rgName -Name $diskName
(Get-AzDisk -ResourceGroupName $rgName -Name $diskName).Sku
New-AzDiskUpdateConfig -Sku Premium_LRS | Update-AzDisk -ResourceGroupName $rgName
-DiskName $diskName
(Get-AzDisk -ResourceGroupName $rgName -Name $diskName).Sku

Bash

LOCATION=$(az group show --name 'az104-03c-rg1' --query location --out tsv)

RGNAME='az104-03d-rg1'

az group create --name $RGNAME --location $LOCATION

az group show --name $RGNAME

DISKNAME='az104-03d-disk1'

az disk create \
--resource-group $RGNAME \
--name $DISKNAME \
--sku 'Standard_LRS' \
--size-gb 32

az disk show --resource-group $RGNAME --name $DISKNAME


az disk update --resource-group $RGNAME --name $DISKNAME --size-gb 64
az disk update --resource-group $RGNAME --name $DISKNAME --sku 'Premium_LRS'
az disk show --resource-group $RGNAME --name $DISKNAME --query sku

az group list --query "[?starts_with(name,'az104-03')].name" --output tsv


az group list --query "[?starts_with(name,'az104-03')].[name]" --output tsv | xargs
-L1 bash -c 'az group delete --name $0 --no-wait --yes'

You might also like