Open NachoHawk opened 5 years ago
I just pushed a fix that should resolve this. Let me know how you fare now.
It didn't fix this issue and the restore function is broken by it. The root cause of this issue is the "-" is contained in the vm name, so, split the snapshot name by "-", will split the vm name too. This fix is trying to split by "AzVmSnapshot-", and it will get the vmname with timestamp. so the vm not found issue is still existing.
According to the naming rule of snapshot, suggest to change following line
$vmName = ($Snapshot.Name -split 'AzVmSnapshot-')[1]
to
$vmName = $Snapshot.Name.substring("AzVmSnapshot-".length, $Snapshot.Name.LastIndexOf('-') - "AzVmSnapshot-".length)
@ajunlee Would you mind issuing a PR?
When trying to restore snapshot getting error "The Resource 'Microsoft.Compute/virtualMachines/Win' under resource group 'xxxxxx' was not found." Get-AzVM shows that the resource is there
CloseError: (:) [Get-AzVM], ### ### ComputeCloudException