Dante Nahuel Ciai
Dante Nahuel Ciai

Reputation: 179

How to initialize/format Azure Windows VM's Data Disks from ARM Template Deployment?

I'm trying to deploy Azure Windows VMs using ARM Templates.

Although I've managed to add Data Disks to the Template, I then have to initialize them at the OS level from Disk Management.

Is there a way to initialize and format them automatically, while making the deployment?

How does the Azure Portal do it when you deploy from it?

Upvotes: 1

Views: 1691

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 89371

Use a custom script extension, and this can all be done in Powershell, eg

PS C:\>Get-Disk | Where-Object OperationalStatus -eq 'Offline'| 
         Initialize-Disk -PartitionStyle GPT -PassThru |
            New-Volume -FileSystem NTFS -DriveLetter F -FriendlyName 'New-Volume'

https://learn.microsoft.com/en-us/powershell/module/storage/new-volume?view=win10-ps

Upvotes: 3

Related Questions