public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var parameters = new VirtualMachineCaptureParameters { DestinationContainerName = DestinationContainerName, OverwriteVhds = Overwrite.IsPresent, VhdPrefix = VHDNamePrefix }; var op = this.VirtualMachineClient.CaptureWithHttpMessagesAsync( this.ResourceGroupName, this.Name, parameters).GetAwaiter().GetResult(); var result = ComputeAutoMapperProfile.Mapper.Map <PSComputeLongRunningOperation>(op); result.StartTime = this.StartTime; result.EndTime = DateTime.Now; if (!string.IsNullOrWhiteSpace(this.Path)) { File.WriteAllText(ResolveUserPath(this.Path), op.Body.Resources[0].ToString()); } WriteObject(result); }); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { var parameters = new VirtualMachineCaptureParameters { DestinationContainerName = DestinationContainerName, OverwriteVhds = Overwrite.IsPresent, VhdPrefix = VHDNamePrefix }; var op = this.VirtualMachineClient.CaptureWithHttpMessagesAsync( this.ResourceGroupName, this.Name, parameters).GetAwaiter().GetResult(); var result = Mapper.Map <PSAzureOperationResponse>(op); if (!string.IsNullOrWhiteSpace(this.Path)) { File.WriteAllText(this.Path, op.Body.Output.ToString()); } WriteObject(result); }); }
protected override void ProcessRecord() { base.ProcessRecord(); ExecuteClientAction(() => { var parameters = new VirtualMachineCaptureParameters { DestinationContainerName = DestinationContainerName, Overwrite = Overwrite.IsPresent, VirtualHardDiskNamePrefix = VHDNamePrefix }; var op = this.VirtualMachineClient.Capture( this.ResourceGroupName, this.Name, parameters); var result = Mapper.Map <PSComputeLongRunningOperation>(op); if (!string.IsNullOrWhiteSpace(this.Path)) { File.WriteAllText(this.Path, result.Output); } WriteObject(result); }); }
protected PSArgument[] CreateVirtualMachineCaptureParameters() { string resourceGroupName = string.Empty; string vmName = string.Empty; VirtualMachineCaptureParameters parameters = new VirtualMachineCaptureParameters(); return(ConvertFromObjectsToArguments( new string[] { "ResourceGroupName", "VMName", "Parameters" }, new object[] { resourceGroupName, vmName, parameters })); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); var parameters = new VirtualMachineCaptureParameters { DestinationContainerName = DestinationContainerName, Overwrite = Overwrite.IsPresent, VirtualHardDiskNamePrefix = VHDNamePrefix }; var op = this.VirtualMachineClient.Capture( this.ResourceGroupName, this.VMName, parameters); WriteObject(op); }
protected void ExecuteVirtualMachineCaptureMethod(object[] invokeMethodInputParameters) { string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]); string vmName = (string)ParseParameter(invokeMethodInputParameters[1]); var parameters = new VirtualMachineCaptureParameters(); var pVhdPrefix = (string)ParseParameter(invokeMethodInputParameters[2]); parameters.VhdPrefix = pVhdPrefix; var pOverwriteVhds = (bool)ParseParameter(invokeMethodInputParameters[3]); parameters.OverwriteVhds = pOverwriteVhds; var pDestinationContainerName = (string)ParseParameter(invokeMethodInputParameters[4]); parameters.DestinationContainerName = pDestinationContainerName; var result = VirtualMachinesClient.Capture(resourceGroupName, vmName, parameters); WriteObject(result); }
///GENMHASH:E5D7B16A7B6C705114CC71E8BB2B20E1:6975A84E6594FF8DEA88E6C992B0B500 public async Task <string> CaptureAsync( string groupName, string name, string containerName, string vhdPrefix, bool overwriteVhd, CancellationToken cancellationToken = default(CancellationToken)) { VirtualMachineCaptureParameters parameters = new VirtualMachineCaptureParameters(); parameters.DestinationContainerName = containerName; parameters.OverwriteVhds = overwriteVhd; parameters.VhdPrefix = vhdPrefix; using (var _result = await((VirtualMachinesOperations)Manager.Inner.VirtualMachines).CaptureWithHttpMessagesAsync(groupName, name, parameters, null, cancellationToken).ConfigureAwait(false)) { var content = await _result.Response.Content.ReadAsStringAsync().ConfigureAwait(false); return(content); } }
internal override void ExecuteCommand() { ServiceManagementProfile.Initialize(); base.ExecuteCommand(); if (CurrentDeploymentNewSM == null) { return; } var parameter = new VirtualMachineCaptureParameters { PostCaptureAction = PostCaptureAction.Delete, TargetImageLabel = string.IsNullOrEmpty(this.NewImageLabel) ? this.NewImageName : this.NewImageLabel, TargetImageName = this.NewImageName }; ExecuteClientActionNewSM( null, CommandRuntime.ToString(), () => this.ComputeClient.VirtualMachines.Capture(this.ServiceName, CurrentDeploymentNewSM.Name, this.Name, parameter)); }
protected override void ExecuteCommand() { ServiceManagementProfile.Initialize(); base.ExecuteCommand(); if (CurrentDeploymentNewSM == null) { return; } var parameter = new VirtualMachineCaptureParameters { PostCaptureAction = PostCaptureAction.Delete, TargetImageLabel = string.IsNullOrEmpty(this.NewImageLabel) ? this.NewImageName : this.NewImageLabel, TargetImageName = this.NewImageName }; ExecuteClientActionNewSM( null, CommandRuntime.ToString(), () => this.ComputeClient.VirtualMachines.Capture(this.ServiceName, CurrentDeploymentNewSM.Name, this.Name, parameter)); }
/// <summary> /// Captures the VM by copying VirtualHardDisks of the VM and outputs a /// template that can be used to create similar VMs. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Compute.IVirtualMachineOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group. /// </param> /// <param name='vmName'> /// Required. The name of the virtual machine. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Capture Virtual Machine /// operation. /// </param> /// <returns> /// The compute long running operation response. /// </returns> public static Task <ComputeOperationResponse> BeginCapturingAsync(this IVirtualMachineOperations operations, string resourceGroupName, string vmName, VirtualMachineCaptureParameters parameters) { return(operations.BeginCapturingAsync(resourceGroupName, vmName, parameters, CancellationToken.None)); }
/// <summary> /// Captures the VM by copying VirtualHardDisks of the VM and outputs a /// template that can be used to create similar VMs. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Compute.IVirtualMachineOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group. /// </param> /// <param name='vmName'> /// Required. The name of the virtual machine. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Capture Virtual Machine /// operation. /// </param> /// <returns> /// The compute long running operation response. /// </returns> public static ComputeOperationResponse BeginCapturing(this IVirtualMachineOperations operations, string resourceGroupName, string vmName, VirtualMachineCaptureParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IVirtualMachineOperations)s).BeginCapturingAsync(resourceGroupName, vmName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public void TestVMOperations() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { EnsureClientsInitialized(context); ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); // Create resource group string rg1Name = ComputeManagementTestUtilities.GenerateName(TestPrefix) + 1; string as1Name = ComputeManagementTestUtilities.GenerateName("as"); string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); VirtualMachine inputVM1; try { // Create Storage Account, so that both the VMs can share it var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName); VirtualMachine vm1 = CreateVM_NoAsyncTracking(rg1Name, as1Name, storageAccountOutput, imageRef, out inputVM1); m_CrpClient.VirtualMachines.Start(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Redeploy(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Restart(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.PowerOff(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Deallocate(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Generalize(rg1Name, vm1.Name); var captureParams = new VirtualMachineCaptureParameters { DestinationContainerName = ComputeManagementTestUtilities.GenerateName(TestPrefix), VhdPrefix = ComputeManagementTestUtilities.GenerateName(TestPrefix), OverwriteVhds = true }; var captureResponse = m_CrpClient.VirtualMachines.Capture(rg1Name, vm1.Name, captureParams); Assert.NotNull(captureResponse.Output); string outputAsString = captureResponse.Output.ToString(); Assert.Equal('{', outputAsString[0]); Assert.True(outputAsString.Contains(captureParams.DestinationContainerName.ToLowerInvariant())); Assert.True(outputAsString.ToLowerInvariant().Contains(captureParams.VhdPrefix.ToLowerInvariant())); Template template = JsonConvert.DeserializeObject <Template>(outputAsString); Assert.True(template.Resources.Count > 0); string imageUri = template.Resources[0].Properties.StorageProfile.OSDisk.Image.Uri; Assert.False(string.IsNullOrEmpty(imageUri)); // Create 2nd VM from the captured image // TODO : Provisioning Time-out Issues VirtualMachine inputVM2; string as2Name = as1Name + "b"; VirtualMachine vm2 = CreateVM_NoAsyncTracking(rg1Name, as2Name, storageAccountOutput, imageRef, out inputVM2, vm => { vm.StorageProfile.ImageReference = null; vm.StorageProfile.OsDisk.Image = new VirtualHardDisk { Uri = imageUri }; vm.StorageProfile.OsDisk.Vhd.Uri = vm.StorageProfile.OsDisk.Vhd.Uri.Replace(".vhd", "copy.vhd"); vm.StorageProfile.OsDisk.OsType = OperatingSystemTypes.Windows; }, false, false); Assert.True(vm2.StorageProfile.OsDisk.Image.Uri == imageUri); } finally { // Cleanup the created resources. But don't wait since it takes too long, and it's not the purpose // of the test to cover deletion. CSM does persistent retrying over all RG resources. m_ResourcesClient.ResourceGroups.Delete(rg1Name); } } }
/// <summary> /// Captures the VM by copying virtual hard disks of the VM and outputs a /// template that can be used to create similar VMs. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='vmName'> /// The name of the virtual machine. /// </param> /// <param name='parameters'> /// Parameters supplied to the Capture Virtual Machine operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <VirtualMachineCaptureResultInner> CaptureAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string vmName, VirtualMachineCaptureParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CaptureWithHttpMessagesAsync(resourceGroupName, vmName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public void TestVMOperations() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { EnsureClientsInitialized(context); ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); // Create resource group string rg1Name = ComputeManagementTestUtilities.GenerateName(TestPrefix) + 1; string as1Name = ComputeManagementTestUtilities.GenerateName("as"); string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); VirtualMachine inputVM1; try { // Create Storage Account, so that both the VMs can share it var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName); VirtualMachine vm1 = CreateVM(rg1Name, as1Name, storageAccountOutput, imageRef, out inputVM1); m_CrpClient.VirtualMachines.Start(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Redeploy(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Restart(rg1Name, vm1.Name); var runCommandImput = new RunCommandInput() { CommandId = "RunPowerShellScript", Script = new List <string>() { "param(", " [string]$arg1,", " [string]$arg2", ")", "echo This is a sample script with parameters $arg1 $arg2" }, Parameters = new List <RunCommandInputParameter>() { new RunCommandInputParameter("arg1", "value1"), new RunCommandInputParameter("arg2", "value2"), } }; RunCommandResult result = m_CrpClient.VirtualMachines.RunCommand(rg1Name, vm1.Name, runCommandImput); Assert.NotNull(result); Assert.NotNull(result.Value); Assert.True(result.Value.Count > 0); m_CrpClient.VirtualMachines.PowerOff(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Deallocate(rg1Name, vm1.Name); m_CrpClient.VirtualMachines.Generalize(rg1Name, vm1.Name); VirtualMachine ephemeralVM; string as2Name = as1Name + "_ephemeral"; CreateVM(rg1Name, as2Name, storageAccountName, imageRef, out ephemeralVM, hasManagedDisks: true, hasDiffDisks: true, vmSize: VirtualMachineSizeTypes.StandardDS1V2, osDiskStorageAccountType: StorageAccountTypes.StandardLRS, dataDiskStorageAccountType: StorageAccountTypes.StandardLRS); m_CrpClient.VirtualMachines.Reimage(rg1Name, ephemeralVM.Name, tempDisk: true); var captureParams = new VirtualMachineCaptureParameters { DestinationContainerName = ComputeManagementTestUtilities.GenerateName(TestPrefix), VhdPrefix = ComputeManagementTestUtilities.GenerateName(TestPrefix), OverwriteVhds = true }; var captureResponse = m_CrpClient.VirtualMachines.Capture(rg1Name, vm1.Name, captureParams); Assert.NotNull(captureResponse); Assert.True(captureResponse.Resources.Count > 0); string resource = captureResponse.Resources[0].ToString(); Assert.Contains(captureParams.DestinationContainerName.ToLowerInvariant(), resource.ToLowerInvariant()); Assert.Contains(captureParams.VhdPrefix.ToLowerInvariant(), resource.ToLowerInvariant()); Resource template = JsonConvert.DeserializeObject <Resource>(resource); string imageUri = template.Properties.StorageProfile.OSDisk.Image.Uri; Assert.False(string.IsNullOrEmpty(imageUri)); // Create 3rd VM from the captured image // TODO : Provisioning Time-out Issues VirtualMachine inputVM2; string as3Name = as1Name + "b"; VirtualMachine vm3 = CreateVM(rg1Name, as3Name, storageAccountOutput, imageRef, out inputVM2, vm => { vm.StorageProfile.ImageReference = null; vm.StorageProfile.OsDisk.Image = new VirtualHardDisk { Uri = imageUri }; vm.StorageProfile.OsDisk.Vhd.Uri = vm.StorageProfile.OsDisk.Vhd.Uri.Replace(".vhd", "copy.vhd"); vm.StorageProfile.OsDisk.OsType = OperatingSystemTypes.Windows; }, false, false); Assert.True(vm3.StorageProfile.OsDisk.Image.Uri == imageUri); } finally { // Cleanup the created resources. But don't wait since it takes too long, and it's not the purpose // of the test to cover deletion. CSM does persistent retrying over all RG resources. m_ResourcesClient.ResourceGroups.Delete(rg1Name); } } }
public void TestVMOperations() { using (var context = UndoContext.Current) { context.Start(); EnsureClientsInitialized(); string imgRefId = GetPlatformOSImage(useWindowsImage: true); // Create resource group string rg1Name = TestUtilities.GenerateName(TestPrefix) + 1; string asName = TestUtilities.GenerateName("as"); string storageAccountName = TestUtilities.GenerateName(TestPrefix); VirtualMachine inputVM1; bool passed = false; try { // Create Storage Account, so that both the VMs can share it var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName); VirtualMachine vm1 = CreateVM(rg1Name, asName, storageAccountOutput, imgRefId, out inputVM1); var startOperationResponse = m_CrpClient.VirtualMachines.BeginStarting(rg1Name, vm1.Name); Assert.Equal(HttpStatusCode.Accepted, startOperationResponse.StatusCode); ComputeLongRunningOperationResponse lroResponse = m_CrpClient.VirtualMachines.Start(rg1Name, vm1.Name); Assert.Equal(ComputeOperationStatus.Succeeded, lroResponse.Status); var stopOperationResponse = m_CrpClient.VirtualMachines.BeginPoweringOff(rg1Name, vm1.Name); Assert.Equal(HttpStatusCode.Accepted, startOperationResponse.StatusCode); lroResponse = m_CrpClient.VirtualMachines.PowerOff(rg1Name, vm1.Name); Assert.Equal(ComputeOperationStatus.Succeeded, lroResponse.Status); var restartOperationResponse = m_CrpClient.VirtualMachines.BeginRestarting(rg1Name, vm1.Name); Assert.Equal(HttpStatusCode.Accepted, startOperationResponse.StatusCode); lroResponse = m_CrpClient.VirtualMachines.Restart(rg1Name, vm1.Name); Assert.Equal(ComputeOperationStatus.Succeeded, lroResponse.Status); var deallocateOperationResponse = m_CrpClient.VirtualMachines.BeginDeallocating(rg1Name, vm1.Name); Assert.Equal(HttpStatusCode.Accepted, startOperationResponse.StatusCode); lroResponse = m_CrpClient.VirtualMachines.Deallocate(rg1Name, vm1.Name); Assert.Equal(ComputeOperationStatus.Succeeded, lroResponse.Status); var generalizeResponse = m_CrpClient.VirtualMachines.Generalize(rg1Name, vm1.Name); Assert.Equal(HttpStatusCode.OK, generalizeResponse.StatusCode); var captureParams = new VirtualMachineCaptureParameters { DestinationContainerName = TestUtilities.GenerateName(TestPrefix), VirtualHardDiskNamePrefix = TestUtilities.GenerateName(TestPrefix), Overwrite = true }; ComputeLongRunningOperationResponse captureResponse = m_CrpClient.VirtualMachines.Capture(rg1Name, vm1.Name, captureParams); Assert.Equal(ComputeOperationStatus.Succeeded, captureResponse.Status); Assert.NotNull(captureResponse.Output); string outputAsString = captureResponse.Output; Assert.Equal('{', outputAsString[0]); Assert.True(outputAsString.Contains(captureParams.DestinationContainerName.ToLowerInvariant())); Assert.True(outputAsString.ToLowerInvariant().Contains( captureParams.VirtualHardDiskNamePrefix.ToLowerInvariant())); passed = true; } finally { // Cleanup the created resources. But don't wait since it takes too long, and it's not the purpose // of the test to cover deletion. CSM does persistent retrying over all RG resources. var deleteRg1Response = m_ResourcesClient.ResourceGroups.BeginDeleting(rg1Name); Assert.True(deleteRg1Response.StatusCode == HttpStatusCode.Accepted, "BeginDeleting status was not Accepted."); } Assert.True(passed); } }
/// <summary> /// Captures the VM by copying virtual hard disks of the VM and outputs a /// template that can be used to create similar VMs. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='vmName'> /// The name of the virtual machine. /// </param> /// <param name='parameters'> /// Parameters supplied to the Capture Virtual Machine operation. /// </param> public static VirtualMachineCaptureResult BeginCapture(this IVirtualMachinesOperations operations, string resourceGroupName, string vmName, VirtualMachineCaptureParameters parameters) { return(Task.Factory.StartNew(s => ((IVirtualMachinesOperations)s).BeginCaptureAsync(resourceGroupName, vmName, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public async Task TestVMOperations() { EnsureClientsInitialized(DefaultLocation); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); // Create resource group string rg1Name = Recording.GenerateAssetName(TestPrefix) + 1; string as1Name = Recording.GenerateAssetName("as"); string storageAccountName = Recording.GenerateAssetName(TestPrefix); VirtualMachine inputVM1; // Create Storage Account, so that both the VMs can share it var storageAccountOutput = await CreateStorageAccount(rg1Name, storageAccountName); var returnTwovm = await CreateVM(rg1Name, as1Name, storageAccountOutput, imageRef); var vm1 = returnTwovm.Item1; inputVM1 = returnTwovm.Item2; await WaitForCompletionAsync(await VirtualMachinesOperations.StartStartAsync(rg1Name, vm1.Name)); await WaitForCompletionAsync(await VirtualMachinesOperations.StartRedeployAsync(rg1Name, vm1.Name)); await WaitForCompletionAsync(await VirtualMachinesOperations.StartRestartAsync(rg1Name, vm1.Name)); var runCommandImput = new RunCommandInput("RunPowerShellScript") { Script = { "param(", " [string]$arg1,", " [string]$arg2", ")", "echo This is a sample script with parameters $arg1 $arg2" }, Parameters = { new RunCommandInputParameter("arg1", "value1"), new RunCommandInputParameter("arg2", "value2"), } }; RunCommandResult result = (await WaitForCompletionAsync(await VirtualMachinesOperations.StartRunCommandAsync(rg1Name, vm1.Name, runCommandImput))).Value; Assert.NotNull(result); Assert.NotNull(result.Value); Assert.True(result.Value.Count > 0); await WaitForCompletionAsync(await VirtualMachinesOperations.StartPowerOffAsync(rg1Name, vm1.Name)); await WaitForCompletionAsync(await VirtualMachinesOperations.StartDeallocateAsync(rg1Name, vm1.Name)); await VirtualMachinesOperations.GeneralizeAsync(rg1Name, vm1.Name); VirtualMachine ephemeralVM; string as2Name = as1Name + "_ephemeral"; var returnTwoVM = await CreateVM(rg1Name, as2Name, storageAccountName, imageRef, hasManagedDisks : true, hasDiffDisks : true, vmSize : VirtualMachineSizeTypes.StandardDS5V2.ToString(), osDiskStorageAccountType : StorageAccountTypes.StandardLRS.ToString(), dataDiskStorageAccountType : StorageAccountTypes.StandardLRS.ToString()); ephemeralVM = returnTwoVM.Item2; await WaitForCompletionAsync(await VirtualMachinesOperations.StartReimageAsync(rg1Name, ephemeralVM.Name)); var captureParams = new VirtualMachineCaptureParameters(Recording.GenerateAssetName(TestPrefix), Recording.GenerateAssetName(TestPrefix), true); var captureResponse = await WaitForCompletionAsync(await VirtualMachinesOperations.StartCaptureAsync(rg1Name, vm1.Name, captureParams)); Assert.NotNull(captureResponse); Assert.True(captureResponse.Value.Resources.Count > 0); string resource = captureResponse.Value.Resources[0].ToString(); Assert.IsTrue(resource.ToLowerInvariant().Contains(captureParams.DestinationContainerName.ToLowerInvariant())); Assert.IsTrue(resource.ToLowerInvariant().Contains(captureParams.VhdPrefix.ToLowerInvariant())); Resource template = JsonSerializer.Deserialize <Resource>(resource); string imageUri = template.Properties.StorageProfile.OSDisk.Image.Uri; Assert.False(string.IsNullOrEmpty(imageUri)); // Create 3rd VM from the captured image // TODO : Provisioning Time-out Issues VirtualMachine inputVM2; string as3Name = as1Name + "b"; returnTwovm = await CreateVM(rg1Name, as3Name, storageAccountOutput, imageRef, vm => { vm.StorageProfile.ImageReference = null; vm.StorageProfile.OsDisk.Image = new VirtualHardDisk { Uri = imageUri }; vm.StorageProfile.OsDisk.Vhd.Uri = vm.StorageProfile.OsDisk.Vhd.Uri.Replace(".vhd", "copy.vhd"); vm.StorageProfile.OsDisk.OsType = OperatingSystemTypes.Windows; }, false, false); var vm3 = returnTwovm.Item1; inputVM2 = returnTwovm.Item2; Assert.True(vm3.StorageProfile.OsDisk.Image.Uri == imageUri); }