-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28cff98
commit ee1acc2
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#region Copy snapshot to storage any account | ||
$storageAccountName = "ayn" | ||
$storageAccountKey = '<>' | ||
$absoluteUri = 'https://<>.blob.core.windows.net/<>/' | ||
$destContainer = 'vhds' | ||
$blobName = 'server.vhd' | ||
|
||
$destContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey | ||
Start-AzureStorageBlobCopy -AbsoluteUri $absoluteUri -DestContainer $destContainer -DestContext $destContext -DestBlob $blobName | ||
#endregion | ||
|
||
|
||
#region Copy a managed disk to storage any account | ||
$sas = Grant-AzDiskAccess -ResourceGroupName W10VmRG -DiskName W10D -DurationInSecond 3600 -Access Read | ||
$storageAccountContext = New-AzStorageContext -StorageAccountName diskexport1 -StorageAccountKey '<>' | ||
New-AzStorageContainer -Context $storageAccountContext -Name diskexportcont -Verbose | ||
Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer diskexportcont -DestContext $storageAccountContext -DestBlob w10.vhd | ||
|
||
$a= Get-AzStorageBlobCopyState -Container diskexportcont -Blob w10.vhd -Context $storageAccountContext | ||
($a.BytesCopied/$a.TotalBytes).ToString("P") #Output: 40.389% | ||
#endregion | ||
|
||
|
||
|
||
#region Expand a vhd | ||
$rgName = 'Infra_VMs' | ||
$vmName = 'A20VL001' | ||
|
||
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName | ||
|
||
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName | ||
|
||
$vm.StorageProfile.OSDisk.DiskSizeGB = 2048 | ||
Update-AzureRmVM -ResourceGroupName $rgName -VM $vm | ||
|
||
Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName | ||
#endregion |