DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Grow Your Skills With Low-Code Automation Tools
  • Hiding Data in Cassandra
  • Getting Started With the YugabyteDB Managed REST API
  • Microservices With Apache Camel and Quarkus (Part 3)

Trending

  • Grow Your Skills With Low-Code Automation Tools
  • Hiding Data in Cassandra
  • Getting Started With the YugabyteDB Managed REST API
  • Microservices With Apache Camel and Quarkus (Part 3)
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Resizing Data Disks in the Cloud on Microsoft Azure with Windows PowerShell

Resizing Data Disks in the Cloud on Microsoft Azure with Windows PowerShell

Keith Mayer user avatar by
Keith Mayer
·
Apr. 02, 15 · Interview
Like (0)
Save
Tweet
Share
5.89K Views

Join the DZone community and get the full member experience.

Join For Free

Resizing existing Azure VM data disks just got a whole lot easier with the introduction of an enhanced Update-AzureDisk PowerShell cmdlet in the latest version of the Azure PowerShell module.

Click to zoom ...

In this article, I’ll step through the process of using this new cmdlet to increase the size of an existing data disk on an Azure virtual machine.

Getting started …

To follow along with the steps in this article, you’ll need an active Azure subscription and the latest version of the Azure PowerShell module, which is version 0.8.15.1 as of this article’s date.

  • Sign-up for a FREE Azure trial subscription, or Activate your Azure MSDN benefits
  • Download and install the latest Azure PowerShell Module

In order to resize an existing VM data disk, you’ll also need to have at least one VM provisioned with a data disk attached.

  • Create a new Azure Virtual Machine
  • Attach a Data Disk to an Azure VM

Resize Azure Data Disks via Azure PowerShell Script

Below, I’ve included a sample Azure PowerShell snippet that you can incorporate into your own script for increasing the size of existing Azure VM data disks.

    # Authenticate to Azure Account
     
    Add-AzureAccount

    # Select Azure Subscription
     
    $subscription =
        (Get-AzureSubscription).SubscriptionName `
        | Out-GridView `
            -Title "Select Azure Subscription" `
             -PassThru
     
    Select-AzureSubscription `
        -SubscriptionName $subscription `
        -Current

    # Select Azure Storage Account
     
    $storageAccount =
        (Get-AzureStorageAccount).Label `
        | Out-GridView `
            -Title "Select Azure Storage Account" `
            -PassThru
     
    Set-AzureSubscription `
        -SubscriptionName $subscription `
        -CurrentStorageAccountName $storageAccount

    # Select Azure VM
     
    $vm =
        Get-AzureVM `
        | Out-GridView `
            -Title "Select a VM ..." `
             -PassThru

    # Select Data Disk to resize
     
    $disk =
        $vm `
        | Get-AzureDataDisk `
        | Out-GridView `
            -Title "Select a data disk to resize" `
            -PassThru
     
    $diskName = $disk.DiskName

    # Specify new Data Disk size – must be larger than current size
     
    do {
     
        $size =
            Read-Host `
                -Prompt "New size in GB"

    }

    until ( $size -gt $disk.LogicalDiskSizeInGB )

    # Stop and Deallocate VM prior to resizing data disk
     
    $vm `
        | Stop-AzureVM `
             -Force

    # Resize Data Disk to Larger Size
     
    Update-AzureDisk `
        -Label "$diskName" `
        -DiskName "$diskName" `
        -ResizedSizeInGB $size

    # Start VM

    $vm | Start-AzureVM

Extending the Data Volume

After updating the data disk to a larger size, you’ll need to extend the file system volume on that data disk to be able to access the additional space.  You can easily perform this task using Server Manager from within a Remote Desktop connection to the Azure VM.

Click to zoom ...
Extending Existing Data Volume on a Resized Data Disk

azure Data (computing) PowerShell Virtual Machine Cloud

Published at DZone with permission of Keith Mayer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Grow Your Skills With Low-Code Automation Tools
  • Hiding Data in Cassandra
  • Getting Started With the YugabyteDB Managed REST API
  • Microservices With Apache Camel and Quarkus (Part 3)

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: