다음을 통해 공유


Azure: deploy VM with powershell

Set the PowerShell Execution Policy as required

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Download and install the Azure module in your computer

Install-Module AzureRM -AllowClobber

PS Script

Run the ps script for the deployment found along with the template.

Please remember to substitute the values including the subscription ID from the Azure portal

PS C:\Users\mphilip\Desktop\Azure> .\deploy.ps1

cmdlet deploy.ps1 at command pipeline position 1

Supply values for the following parameters:

subscriptionId:

resourceGroupName: test

deploymentName: test

Logging in…

When asked, also provide the value for resourceGroupLocation, we have provided the value ‘southindia’ and you may provide it as per your preference. You will have to provide the azure login credentials too when asked

Another way of running the script is to add the required parameters along with script as below

.\deploy.ps1 -subscriptionId xxxx -resourceGroupName test -deploymentName test

Handling some errors

Suppose, you found certain errors reported as

“New-AzureRmResourceGroupDeployment : 2:12:05 PM – Error: Code=InvalidDeploymentParameterValue; Message=The value of deployment parameter ‘adminPassword’ is null. Please specify the value or use the parameter reference.”

You will need to fix the value for adminpassword of the vm to be created in parameter file, by preference you hash and secure the password, and don't write it in plain text in your scripts.

It can be ‘null’ in your parameter file.