Loading Variables

Loading the necessary variables requires three commands. The first command loads the existing snapshot that was created into a variable, called $snapshot. The snapshot info needs to be loaded into a variable so that it can be more easily referenced in commands used later in the process.

Load the snapshot config for the mySnaphsot snapshot into a variable by running the following command:

$snapshot = Get-AzureRmSnapshot `
-ResourceGroupName 'VMLab' `
-SnapshotName 'mySnapshot'

Once the snapshot config is loaded into a variable, you need to create a new disk configuration and load that into a separate variable so that it, too, can be referenced more easily:

$diskConfig = New-AzureRmDiskConfig `
-Location $snapshot.Location `
-SourceResourceId $snapshot.Id `
-CreateOption Copy

After loading the new disk configuration into a variable, using the preceding command, you need to create a new OS disk resource based on the configuration you just loaded. To create the OS disk resource based on the preceding configuration, run the NewAzureRmDisk command: 

$disk = New-AzureRmDisk `
-Disk $diskConfig `
-ResourceGroupName VMLab `
-DiskName myOSDisk

None of these three commands is going to produce any feedback on the screen; however, they are loading up the snapshot configuration, creating a disk configuration based on the snapshot that was taken, and provisioning a new OS disk from the snapshot.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.165.246