Deploying VM Using ARM Template

%3CLINGO-SUB%20id%3D%22lingo-sub-1514708%22%20slang%3D%22en-US%22%3EDeploying%20VM%20Using%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1514708%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20guys.%20I'm%20trying%20to%20deploy%20a%20VM%20using%20the%20ARM%20template.%20These%20are%20the%20commands%20below%20that%20was%20run%20in%20PowerShell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eecho%20%22New-AzResourceGroupDeployment%20-Name%20%22dplisvvm%24postfix%22%20-ResourceGroupName%20%22%24rgName%22%20-TemplateFile%20%22VHDtoImage.json%22%20-userStorageAccountName%20%22%24storageaccount%22%20-dnsNameForPublicIP%20%22%24vmName%22%20-subscriptionId%20%22%24mysubid%22%20-location%20%22%24location%22%20-vmName%20%22%24vmName%22%20-vaultName%20%22%24kvname%22%20-vaultResourceGroup%20%22%24rgName%22%20-certificateUrl%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fvaulto.vault.azure.net%2Fkeys%2FArthur%2Fcf9ba64e6bb24adfa943ed9d5ab72ce0.Id%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fvaulto.vault.azure.net%2Fkeys%2FArthur%2Fcf9ba64e6bb24adfa943ed9d5ab72ce0.Id%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-vhdUrl%20%22%24vhdUrl%22%20-vmSize%20%22Standard%5C_A2%22%20-publicIPAddressName%20%22myPublicIP1%22%20-virtualNetworkName%20%22myVNET1%22%20-nicName%20%22myNIC1%22%20-adminUserName%20%22Aruzki19%22%20-adminPassword%20%22Antwaynio97101%23%22%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ENew-AzResourceGroupDeployment%20-Name%20%22dplisvvm%24postfix%22%20-ResourceGroupName%20%22%24rgName%22%20-TemplateFile%20%22VHDtoImage.json%22%20-userStorageAccountName%20%22%24storageaccount%22%20-dnsNameForPublicIP%20%22%24vmName%22%20-subscriptionId%20%22%24mysubid%22%20-location%20%22%24location%22%20-vmName%20%22%24vmName%22%20-vaultName%20%22%24kvname%22%20-vaultResourceGroup%20%22%24rgName%22%20-certificateUrl%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fvaulto.vault.azure.net%2Fkeys%2FArthur%2Fcf9ba64e6bb24adfa943ed9d5ab72ce0.Id%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fvaulto.vault.azure.net%2Fkeys%2FArthur%2Fcf9ba64e6bb24adfa943ed9d5ab72ce0.Id%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-vhdUrl%20%22%24vhdUrl%22%20-vmSize%20%22Standard%5C_A2%22%20-publicIPAddressName%20%22myPublicIP1%22%20-virtualNetworkName%20%22myVNET1%22%20-nicName%20%22myNIC1%22%20-adminUserName%20%22Aruzki19%22%20-adminPassword%20%22Antwaynio97101%23%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20below%20is%20the%20error%20I%20received%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENew-AzResourceGroupDeployment%3A%20Cannot%20bind%20parameter%20'adminPassword'.%20Cannot%20convert%20the%20%22Antwaynio97101%23%22%20value%20of%20type%20%22System.String%22%20to%20type%20%22System.Security.SecureString%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20assist%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1514708%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1516294%22%20slang%3D%22en-US%22%3ERe%3A%20Deploying%20VM%20Using%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1516294%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F725009%22%20target%3D%22_blank%22%3E%40Antwaynio97%3C%2FA%3E%2C%20You%20are%20passing%20the%20password%20as%20a%20plain%20text.%20Rather%20convert%20it%20to%20a%20secure%20string%20and%20try%20again.%20Something%20like%20this%20-%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ENew-AzResourceGroupDeployment%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-Name%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22dplisvvm%3C%2FSPAN%3E%3CSPAN%3E%24postfix%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-ResourceGroupName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24rgName%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-TemplateFile%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22VHDtoImage.json%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-userStorageAccountName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24storageaccount%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-dnsNameForPublicIP%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24vmName%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-subscriptionId%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24mys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3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B-certificateUrl%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fvaulto.vault.azure.net%2Fkeys%2FArthur%2Fcf9ba64e6bb24adfa943ed9d5ab72ce0.Id%26nbsp%3B%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fvaulto.vault.azure.net%2Fkeys%2FArthur%2Fcf9ba64e6bb24adfa943ed9d5ab72ce0.Id%26nbsp%3B%3C%2FA%3E%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-vhdUrl%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24vhdUrl%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-vmSize%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Standard%5C_A2%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-publicIPAddressName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22myPublicIP1%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-virtualNetworkName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22myVNET1%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-nicName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22myNIC1%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-adminUserName%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Aruzki19%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CSPAN%3E-adminPassword%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%22Antwaynio97101%23%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EConvertTo-SecureString%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-AsPlainText%26nbsp%3B-Force)%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1531018%22%20slang%3D%22en-US%22%3ERe%3A%20Deploying%20VM%20Using%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1531018%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F715360%22%20target%3D%22_blank%22%3E%40hkarthik_7%3C%2FA%3E%26nbsp%3B.%20Thanks%20for%20the%20assistance.%20I%20somehow%20encountered%20another%20challenge%20in%20deploying%20the%20VM%20from%20the%20generalized%20image.%20Please%20see%20screenshot%20attached.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1532436%22%20slang%3D%22en-US%22%3ERe%3A%20Deploying%20VM%20Using%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1532436%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F725009%22%20target%3D%22_blank%22%3E%40Antwaynio97%3C%2FA%3E%26nbsp%3B%2C%20this%20is%20because%20there%20are%20no%20parameters%20like%20-adminUsername%2C%20-adminPassword%20and%20similar%20values%20to%20the%20cmdlet%26nbsp%3BNew-AzResourceGroupDeployment.%20You%20have%20to%20specify%20the%20admin%20username%20for%20VM%20in%20the%20parameters%20template%20and%20save%20your%20password%20in%20Azure%20key%20vault%20and%20refer%20the%20URL%20to%20the%20secret%20in%20password%20section.%20Please%20specify%20all%20the%20certificates%20related%20values%2C%20SKU%20size%20of%20the%20VM%2C%20admin%20username%2C%20password%2C%20location%20and%20encapsulate%20everything%20in%20a%20parameters%20file.%20Then%2C%20you%20can%20run%20the%20cmdlet%20like%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ENew-AzResourceGroupDeployment%20-ResourceGroupName%20%22ContosoEngineering%22%20-TemplateFile%20%22D%3A%5CAzure%5CTemplates%5CEngineeringSite.json%22%20-TemplateParameterFile%20%22D%3A%5CAzure%5CTemplates%5CEngSiteParms.json%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20run%20%22help%26nbsp%3BNew-AzResourceGroupDeployment%20-Full%22%20to%20know%20the%20complete%20usage%20of%20cmdlet.%20You%20can%20export%20the%20template%20and%20parameter%20files%2C%20edit%20them%20according%20to%20your%20need%20and%20use%20the%20command%20to%20deploy.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hey guys. I'm trying to deploy a VM using the ARM template. These are the commands below that was run in PowerShell.

 

echo "New-AzResourceGroupDeployment -Name "dplisvvm$postfix" -ResourceGroupName "$rgName" -TemplateFile "VHDtoImage.json" -userStorageAccountName "$storageaccount" -dnsNameForPublicIP "$vmName" -subscriptionId "$mysubid" -location "$location" -vmName "$vmName" -vaultName "$kvname" -vaultResourceGroup "$rgName" -certificateUrl https://vaulto.vault.azure.net/keys/Arthur/cf9ba64e6bb24adfa943ed9d5ab72ce0.Id -vhdUrl "$vhdUrl" -vmSize "Standard\_A2" -publicIPAddressName "myPublicIP1" -virtualNetworkName "myVNET1" -nicName "myNIC1" -adminUserName "Aruzki19" -adminPassword "Antwaynio97101#"


New-AzResourceGroupDeployment -Name "dplisvvm$postfix" -ResourceGroupName "$rgName" -TemplateFile "VHDtoImage.json" -userStorageAccountName "$storageaccount" -dnsNameForPublicIP "$vmName" -subscriptionId "$mysubid" -location "$location" -vmName "$vmName" -vaultName "$kvname" -vaultResourceGroup "$rgName" -certificateUrl https://vaulto.vault.azure.net/keys/Arthur/cf9ba64e6bb24adfa943ed9d5ab72ce0.Id -vhdUrl "$vhdUrl" -vmSize "Standard\_A2" -publicIPAddressName "myPublicIP1" -virtualNetworkName "myVNET1" -nicName "myNIC1" -adminUserName "Aruzki19" -adminPassword "Antwaynio97101#"

 

And below is the error I received 

 

New-AzResourceGroupDeployment: Cannot bind parameter 'adminPassword'. Cannot convert the "Antwaynio97101#" value of type "System.String" to type "System.Security.SecureString".

 

Can anyone assist?

3 Replies
Highlighted

Hello @Antwaynio97, You are passing the password as a plain text. Rather convert it to a secure string and try again. Something like this - 

 

    New-AzResourceGroupDeployment `
        -Name "dplisvvm$postfix" `
        -ResourceGroupName "$rgName" `
        -TemplateFile "VHDtoImage.json" `
        -userStorageAccountName "$storageaccount" `
        -dnsNameForPublicIP "$vmName" `
        -subscriptionId "$mysubid" `
        -location "$location" `
        -vmName "$vmName" `
        -vaultName "$kvname" `
        -vaultResourceGroup "$rgName" `
        -vhdUrl "$vhdUrl" `
        -vmSize "Standard\_A2" `
        -publicIPAddressName "myPublicIP1" `
        -virtualNetworkName "myVNET1" `
        -nicName "myNIC1" `
        -adminUserName "Aruzki19" `
        -adminPassword ("Antwaynio97101#" | ConvertTo-SecureString -AsPlainText -Force)
Highlighted

Hello @hkarthik_7 . Thanks for the assistance. I somehow encountered another challenge in deploying the VM from the generalized image. Please see screenshot attached. 

Highlighted

Hi @Antwaynio97 , this is because there are no parameters like -adminUsername, -adminPassword and similar values to the cmdlet New-AzResourceGroupDeployment. You have to specify the admin username for VM in the parameters template and save your password in Azure key vault and refer the URL to the secret in password section. Please specify all the certificates related values, SKU size of the VM, admin username, password, location and encapsulate everything in a parameters file. Then, you can run the cmdlet like 

New-AzResourceGroupDeployment -ResourceGroupName "ContosoEngineering" -TemplateFile "D:\Azure\Templates\EngineeringSite.json" -TemplateParameterFile "D:\Azure\Templates\EngSiteParms.json"

 

Please run "help New-AzResourceGroupDeployment -Full" to know the complete usage of cmdlet. You can export the template and parameter files, edit them according to your need and use the command to deploy.