Last active
June 8, 2017 09:37
-
-
Save amoretspero/cbadd4601c1a538cc385b25a6065be4d to your computer and use it in GitHub Desktop.
azure-cli template for azure vm creation with existing vhd file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
===Prerequisites=== | |
1. Azure Cli (on bash on Ubuntu on Windows OR powershell OR Linux shell OR MacOS) | |
2. vhd image of previously deployed VM | |
3. storage account to add vhd. | |
===Steps=== | |
1. Create Storage account in Azure portal or azure-cli. | |
Storage account type does not matter. Choose at your needs. | |
2. Create container named 'vhds' in created storage account. | |
3. Uploaded prepared vhd image of VM to container named 'vhds'. | |
4. In azure-cli commandline, type following. | |
az vm create \ | |
--name <YOUR_VM_NAME> \ | |
--resource-group <RESOURCE_GROUP_TO_DEPLOY_VM_TO> \ | |
--attach-os-disk <URI_OF_VHD_FILE_IN_STORAGE_ACCOUNT> \ | |
--size <YOUR_VM_SIZE> \ | |
--authentication-type <YOUR_VM_AUTHENTICATION_TYPE> \ | |
--admin-username <YOUR_ADMIN_NAME> \ | |
--admin-password <YOUR_ADMIN_PASSWORD> \ | |
--ssh-key-value <YOUR_SSH_PUBLIC_KEY> \ | |
--nsg-rule SSH \ | |
--os-type <YOUR_OS_TYPE> \ | |
--use-unmanaged-disk | |
ex: (Password authentication, Linux) | |
az vm create \ | |
--name vm-test \ | |
--resource-group vm-test-rg \ | |
--attach-os-disk http://teststorage.blob.core.windows.net/vhds/osdisk.vhd \ | |
--size Standard_DS1_v2 \ | |
--authentication-type password \ | |
--admin-username admin \ | |
--admin-password Passw0rd! \ | |
--nsg-rule SSH \ | |
--os-type linux \ | |
--use-unmanged-disk | |
note: | |
1) '--name' and '--resource-group' option is REQUIRED. | |
2) For --size option value, check https://azure.microsoft.com/en-us/pricing/details-virtual-mahines/ | |
3) '--admin-password' option is only used with '--authentication-type' of 'password'. | |
4) For SSH public key authentication, use '--authentication-type' of 'ssh' and provide key value to option '--ssh-key-value'. | |
5) '--os-type' should be one of 'linux' and 'windows'. | |
5. Check azure portal for result. Result will also appear in command line. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment