You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -30,30 +30,22 @@ You have two options to create a custom disk:
30
30
* Upload a VHD
31
31
* Copy an existing Azure VM
32
32
33
-
## Quick commands
34
-
35
-
When creating a new VM with [az vm create](/cli/azure/vm#az-vm-create) from a customized or specialized disk, you **attach** the disk (--attach-os-disk) rather than specifying a custom or marketplace image (--image). The following example creates a VM named *myVM* using the managed disk named *myManagedDisk* created from your customized VHD:
36
-
37
-
```azurecli
38
-
az vm create --resource-group myResourceGroup --location eastus --name myVM \
39
-
--os-type linux --attach-os-disk myManagedDisk
40
-
```
41
33
42
34
## Requirements
43
35
To complete the following steps, you'll need:
44
36
45
-
* A Linux virtual machine that has been prepared for use in Azure. The [Prepare the VM](#prepare-the-vm) section of this article covers how to find distro-specific information on installing the Azure Linux Agent (waagent), which is needed for you to connect to a VM with SSH.
46
-
* The VHD file from an existing [Azure-endorsed Linux distribution](endorsed-distros.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) (or see [information for non-endorsed distributions](create-upload-generic.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)) to a virtual disk in the VHD format. Multiple tools exist to create a VM and VHD:
47
-
* Install and configure [QEMU](https://en.wikibooks.org/wiki/QEMU/Installing_QEMU) or [KVM](https://www.linux-kvm.org/page/RunningKVM), taking care to use VHD as your image format. If needed, you can [convert an image](https://en.wikibooks.org/wiki/QEMU/Images#Converting_image_formats) with `qemu-img convert`.
48
-
* You can also use Hyper-V [on Windows 10](https://msdn.microsoft.com/virtualization/hyperv_on_windows/quick_start/walkthrough_install) or [on Windows Server 2012/2012 R2](https://technet.microsoft.com/library/hh846766.aspx).
37
+
- A Linux virtual machine that has been prepared for use in Azure. The [Prepare the VM](#prepare-the-vm) section of this article covers how to find distro-specific information on installing the Azure Linux Agent (waagent), which is needed for you to connect to a VM with SSH.
38
+
- The VHD file from an existing [Azure-endorsed Linux distribution](endorsed-distros.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) (or see [information for non-endorsed distributions](create-upload-generic.md?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)) to a virtual disk in the VHD format. Multiple tools exist to create a VM and VHD:
39
+
- Install and configure [QEMU](https://en.wikibooks.org/wiki/QEMU/Installing_QEMU) or [KVM](https://www.linux-kvm.org/page/RunningKVM), taking care to use VHD as your image format. If needed, you can [convert an image](https://en.wikibooks.org/wiki/QEMU/Images#Converting_image_formats) with `qemu-img convert`.
40
+
- You can also use Hyper-V [on Windows 10](https://msdn.microsoft.com/virtualization/hyperv_on_windows/quick_start/walkthrough_install) or [on Windows Server 2012/2012 R2](https://technet.microsoft.com/library/hh846766.aspx).
49
41
50
42
> [!NOTE]
51
43
> The newer VHDX format is not supported in Azure. When you create a VM, specify VHD as the format. If needed, you can convert VHDX disks to VHD with [qemu-img convert](https://en.wikibooks.org/wiki/QEMU/Images#Converting_image_formats) or the [Convert-VHD](https://technet.microsoft.com/library/hh848454.aspx) PowerShell cmdlet. Azure does not support uploading dynamic VHDs, so you'll need to convert such disks to static VHDs before uploading. You can use tools such as [Azure VHD Utilities for GO](https://github.com/Microsoft/azure-vhd-utils-for-go) to convert dynamic disks during the process of uploading them to Azure.
52
44
>
53
45
>
54
46
55
47
56
-
* Make sure that you have the latest [Azure CLI](/cli/azure/install-az-cli2) installed and you are signed in to an Azure account with [az login](/cli/azure/reference-index#az-login).
48
+
- Make sure that you have the latest [Azure CLI](/cli/azure/install-az-cli2) installed and you are signed in to an Azure account with [az login](/cli/azure/reference-index#az-login).
57
49
58
50
In the following examples, replace example parameter names with your own values, such as *myResourceGroup*, *mystorageaccount*, and *mydisks*.
59
51
@@ -80,98 +72,16 @@ Also see the [Linux Installation Notes](create-upload-generic.md#general-linux-i
80
72
81
73
## Option 1: Upload a VHD
82
74
83
-
You can upload a customized VHD that you have running on a local machine or that you exported from another cloud. To use a VHD to create a new Azure VM, you'll need to upload the VHD to a storage account and create a managed disk from the VHD. For more information, see [Azure Managed Disks overview](../windows/managed-disks-overview.md).
84
-
85
-
### Create a resource group
86
-
87
-
Before uploading your custom disk and creating VMs, you'll need to create a resource group with [az group create](/cli/azure/group#az-group-create).
88
-
89
-
The following example creates a resource group named *myResourceGroup* in the *eastus* location:
90
-
91
-
```azurecli
92
-
az group create \
93
-
--name myResourceGroup \
94
-
--location eastus
95
-
```
96
-
97
-
### Create a storage account
98
-
99
-
Create a storage account for your custom disk and VMs with [az storage account create](/cli/azure/storage/account). The following example creates a storage account named *mystorageaccount* in the resource group previously created:
100
-
101
-
```azurecli
102
-
az storage account create \
103
-
--resource-group myResourceGroup \
104
-
--location eastus \
105
-
--name mystorageaccount \
106
-
--kind Storage \
107
-
--sku Standard_LRS
108
-
```
109
-
110
-
### List storage account keys
111
-
Azure generates two 512-bit access keys for each storage account. These access keys are used when authenticating to the storage account, such as when carrying out write operations. For more information, see [managing access to storage](../../storage/common/storage-account-manage.md#access-keys).
112
-
113
-
You view the access keys with [az storage account keys list](/cli/azure/storage/account/keys#az-storage-account-keys-list). For example, to view the access keys for the storage account you created:
114
-
115
-
```azurecli
116
-
az storage account keys list \
117
-
--resource-group myResourceGroup \
118
-
--account-name mystorageaccount
119
-
```
120
-
121
-
The output is similar to:
75
+
You can now upload VHD straight into a managed disk. For instructions, see [Upload a VHD to Azure using Azure CLI] (disks-upload-vhd-to-managed-disk-cli).
data: key1 d4XAvZzlGAgWdvhlWfkZ9q4k9bYZkXkuPCJ15NTsQOeDeowCDAdB80r9zA/tUINApdSGQ94H9zkszYyxpe8erw== Full
129
-
data: key2 Ww0T7g4UyYLaBnLYcxIOTVziGAAHvU+wpwuPvK4ZG0CDFwu/mAxS/YYvAQGHocq1w7/3HcalbnfxtFdqoXOw8g== Full
130
-
info: storage account keys list command OK
131
-
```
132
-
Make a note of **key1** as you will use it to interact with your storage account in the next steps.
133
-
134
-
### Create a storage container
135
-
In the same way that you create different directories to logically organize your local file system, you'll create containers within a storage account to organize your disks. A storage account can contain many containers. Create a container with [az storage container create](/cli/azure/storage/container#az-storage-container-create).
136
-
137
-
The following example creates a container named *mydisks*:
138
-
139
-
```azurecli
140
-
az storage container create \
141
-
--account-name mystorageaccount \
142
-
--name mydisks
143
-
```
144
-
145
-
### Upload the VHD
146
-
Upload your custom disk with [az storage blob upload](/cli/azure/storage/blob#az-storage-blob-upload). You'll upload and store your custom disk as a page blob.
147
-
148
-
Specify your access key, the container you created in the previous step, and then the path to the custom disk on your local computer:
149
-
150
-
```azurecli
151
-
az storage blob upload --account-name mystorageaccount \
152
-
--account-key key1 \
153
-
--container-name mydisks \
154
-
--type page \
155
-
--file /path/to/disk/mydisk.vhd \
156
-
--name myDisk.vhd
157
-
```
158
-
Uploading the VHD may take a while.
159
-
160
-
### Create a managed disk
161
-
162
-
163
-
Create a managed disk from the VHD with [az disk create](/cli/azure/disk#az-disk-create). The following example creates a managed disk named *myManagedDisk* from the VHD you uploaded to your named storage account and container:
You can also create a customized VM in Azure and then copy the OS disk and attach it to a new VM to create another copy. This is fine for testing, but if you want to use an existing Azure VM as the model for multiple new VMs, create an *image* instead. For more information about creating an image from an existing Azure VM, see [Create a custom image of an Azure VM by using the CLI](tutorial-custom-images.md).
174
80
81
+
If you want to copy an existing VM to another region, you might want to use azcopy to [creat a copy of a disk in anothre region](disks-upload-vhd-to-managed-disk-cli.md#copy-a-managed-disk).
82
+
83
+
Otherwise, you should take a snapshot of the VM and then create a new OS VHD from the snapshot.
84
+
175
85
### Create a snapshot
176
86
177
87
This example creates a snapshot of a VM named *myVM* in resource group *myResourceGroup* and creates a snapshot named *osDiskSnapshot*.
@@ -60,100 +58,15 @@ Use the VHD as-is to create a new VM.
60
58
* Make sure the VM is configured to get the IP address and DNS settings from DHCP. This ensures that the server obtains an IP address within the virtual network when it starts up.
61
59
62
60
63
-
### Get the storage account
64
-
You'll need a storage account in Azure to store the uploaded VHD. You can either use an existing storage account or create a new one.
65
-
66
-
Show the available storage accounts.
67
-
68
-
```powershell
69
-
Get-AzStorageAccount
70
-
```
71
-
72
-
To use an existing storage account, proceed to the [Upload the VHD](#upload-the-vhd-to-your-storage-account) section.
73
-
74
-
Create a storage account.
75
-
76
-
1. You'll need the name of the resource group where the storage account will be created. Use Get-AzResourceGroup see all the resource groups that are in your subscription.
77
-
78
-
```powershell
79
-
Get-AzResourceGroup
80
-
```
81
-
82
-
Create a resource group named *myResourceGroup* in the *West US* region.
83
-
84
-
```powershell
85
-
New-AzResourceGroup `
86
-
-Name myResourceGroup `
87
-
-Location "West US"
88
-
```
89
-
90
-
2. Create a storage account named *mystorageaccount* in the new resource group by using the [New-AzStorageAccount](https://docs.microsoft.com/powershell/module/az.storage/new-azstorageaccount) cmdlet.
91
-
92
-
```powershell
93
-
New-AzStorageAccount `
94
-
-ResourceGroupName myResourceGroup `
95
-
-Name mystorageaccount `
96
-
-Location "West US" `
97
-
-SkuName "Standard_LRS" `
98
-
-Kind "Storage"
99
-
```
100
-
101
-
### Upload the VHD to your storage account
102
-
Use the [Add-AzVhd](https://docs.microsoft.com/powershell/module/az.compute/add-azvhd) cmdlet to upload the VHD to a container in your storage account. This example uploads the file *myVHD.vhd* from "C:\Users\Public\Documents\Virtual hard disks\" to a storage account named *mystorageaccount* in the *myResourceGroup* resource group. The file is stored in the container named *mycontainer* and the new file name will be *myUploadedVHD.vhd*.
This command may take a while to complete, depending on your network connection and the size of your VHD file.
128
-
129
-
### Create a managed disk from the VHD
130
-
131
-
Create a managed disk from the specialized VHD in your storage account by using [New-AzDisk](https://docs.microsoft.com/powershell/module/az.compute/new-azdisk). This example uses *myOSDisk1* for the disk name, puts the disk in *Standard_LRS* storage, and uses *https://storageaccount.blob.core.windows.net/vhdcontainer/osdisk.vhd* as the URI for the source VHD.
You can now upload a VHD straight into a managed disk. For instructions, see [Upload a VHD to Azure using Azure PowerShell] (disks-upload-vhd-to-managed-disk-powershell.md).
152
64
153
65
## Option 3: Copy an existing Azure VM
154
66
155
67
You can create a copy of a VM that uses managed disks by taking a snapshot of the VM, and then by using that snapshot to create a new managed disk and a new VM.
156
68
69
+
If you want to copy an existing VM to another region, you might want to use azcopy to [creat a copy of a disk in anothre region](disks-upload-vhd-to-managed-disk-powershell.md#copy-a-managed-disk).
0 commit comments