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
This sample demonstrates how to create a Managed Disk from a VHD file.
30
+
Create Managed Disks from VHD files in following scenarios:
31
+
1. Create a Managed OS Disk from a specialized VHD file. A specialized VHD is a copy of VHD from an exisitng VM that maintains the user accounts, applications and other state data from your original VM.
32
+
Attach this Managed Disk as OS disk to create a new virtual machine.
33
+
2. Create a Managed data Disk from a VHD file. Attach the Managed Disk to an existing VM or attach it as data disk to create a new virtual machine.
34
+
35
+
.NOTES
36
+
37
+
1. Before you use this sample, please install the latest version of Azure PowerShell from here: http://go.microsoft.com/?linkid=9811175&clcid=0x409
38
+
2. Provide the appropriate values for each variable. Note: The angled brackets should not be included in the values you provide.
39
+
40
+
41
+
#>
42
+
43
+
#Provide the subscription Id
44
+
$subscriptionId = 'yourSubscriptionId'
45
+
46
+
#Provide the name of your resource group
47
+
$resourceGroupName ='yourResourceGroupName'
48
+
49
+
#Provide the name of the Managed Disk
50
+
$diskName = 'yourDiskName'
51
+
52
+
#Provide the size of the disks in GB. It should be greater than the VHD file size.
53
+
$diskSize = '128'
54
+
55
+
#Provide the URI of the VHD file that will be used to create Managed Disk.
56
+
# VHD file can be deleted as soon as Managed Disk is created.
57
+
# e.g. https://contosostorageaccount1.blob.core.windows.net/vhds/contoso-um-vm120170302230408.vhd
#Provide the storage type for the Managed Disk. PremiumLRS or StandardLRS.
65
+
$sku = 'Premium_LRS'
66
+
67
+
#Provide the Azure location (e.g. westus) where Managed Disk will be located.
68
+
#The location should be same as the location of the storage account where VHD file is stored.
69
+
#Get all the Azure location using command below:
70
+
#Get-AzureRmLocation
71
+
$location = 'westus'
72
+
73
+
#Set the context to the subscription Id where Managed Disk will be created
74
+
Set-AzContext -Subscription $subscriptionId
75
+
76
+
#If you're creating an OS disk, add the following lines
77
+
#Acceptable values are either Windows or Linux
78
+
#$OSType = 'yourOSType'
79
+
#Acceptable values are either V1 or V2
80
+
#$HyperVGeneration = 'yourHyperVGen'
25
81
26
-
[!code-powershell[main](../../../new_powershell_scripts/managed-disks/create-managed-disks-from-vhd-in-different-subscription.ps1"Create managed disk from VHD")]
82
+
#If you're creating an OS disk, add -HyperVGeneration and -OSType parameters
0 commit comments