This is a conversion of ARM template 101-vm-windows-copy-datadisks from the repository azure\azure-quickstart-templates to PowerShell Script.
This script allows you to deploy a simple VM and specify the number of data disks at deploy time using a parameter. Note that the number and size of data disks is bound by the VM size, this sample does not attempt to enforce those rules beyond the size used in this sample, and it will deploy the following resources…
… and in-addition to it, just in-case if the deployment is not successful, then it will rollback the entire deployment.
Note:
If the specified resource group is already exist then the script will not continue with the deployment.
Deploy-AzResource.ps1 [-ResourceGroupName] <string> [-Location] <string> [-DNSLabelPrefix] <string> [[-OSVersion] <string>] [[-NumberOfDataDisks] <int>] [-AdminCredential] <pscredential> [<CommonParameters>]
I 💙 PS> $Credential = Get-Credentials
PowerShell credential request
Enter your credentials.
User: sysadmin
Password for user sysadmin: *************
I 💙 PS> $param = @{
>> ResourceGroupName = 'test-rg'
>> Location = 'westus'
>> DNSLabelPrefix = 'vmwithdatadisks10'
>> NumberOfDataDisks = 10
>> AdminCredential = $Credential
>> }
I 💙 PS> .\Deploy-AzResources.ps1 @param
Deployment is successful!
vmwithdatadisks10.westus.cloudapp.azure.com