question

SamecBrianD-1158 avatar image
0 Votes"
SamecBrianD-1158 asked kobulloc-MSFT edited

Hyper-V Start Configuration - Reset

We have an Azure Lab Services environment where the instructor of the class is requesting that a VM the class uses be able to start up at the same config point each time, allow the students to do their class work, change the VM / etc and then when finished, have the VM go back to its starting point.

Is there a way to Automate this?

Once the initial template VM gets cloned out to all the class VMs, I dont want the instructor to have to login to each VM, open Hyper-V and revert the Hyper-V VM back to its checkpoint.

Thank you ahead of time.

azure-labservices
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SamecBrianD-1158 , Thank you for your question.

Can you please confirm if you are using the Azure Lab Services offering or standalone Azure Virtual Machines? Because the tags on this question reflect only azure-virtual-machines.

Based on this information we can route the question to the appropriate experts.


0 Votes 0 ·

My apologies, this is using Azur Lab Services

0 Votes 0 ·

@SamecBrianD-1158 , Thank you for your response. I am adding appropriate tags so that experts in the area can share their insights.

0 Votes 0 ·
kobulloc-MSFT avatar image
0 Votes"
kobulloc-MSFT answered kobulloc-MSFT edited

Edit:

@SamecBrianD-1158 Sorry for the back and forth here, nested virtualization isn't my area of specialization so I reached out to the product group and the original answer should stand--"Reset" should reset both the VM and the nested VM.

Looking at a diagram I've updated from our documentation on nested virtualization, the medium blue represents the VM that you use and the light blue represents your nested VM. When you use the "Reset" button, both the medium blue and light blue VMs would revert to the state they were in when the lab was published because the light blue client VM’s hard disks are saved on the medium blue’s OS disk.

106300-image.png


image.png (125.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

kobullocMSFT-3723 avatar image
0 Votes"
kobullocMSFT-3723 answered shashishailaj edited

You can quickly reset one or multiple VMs in your lab using the Reset option on the toolbar:

https://docs.microsoft.com/en-us/azure/lab-services/how-to-set-virtual-machine-passwords#reset-vms

104900-image.png



Example

I created a lab then set a template using a Windows 10 machine that I made changes to (Original Configuration document on the desktop). I then published the template and created 3 VMs.

Someone (like a student) used one of the VMs and made some changes (NewChanges document):

104961-image.png

Back in the Azure Lab Services Portal, I went into the lab and clicked on Virtual machine pool. From there, I selected the VMs I wanted to reset and clicked on "Reset" at the top.

104908-image.png

All VMs were reset and the next class has a fresh start:

104909-image.png



image.png (42.3 KiB)
image.png (1.9 MiB)
image.png (116.7 KiB)
image.png (1.9 MiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sorry, I accepted the answer then realized that isnt what I meant.

The issue I am talking about would be nested VMs running inside the Template VM.

Those VMs would need a way to be set back to their checkpoint setup when students were done working with them.

Not the entire Azure Lab Services VM, the nested VMs inside Hyper-V (Hyper-V running on the Azure Lab Services VM).

So using your steps, it would also set all the Hyper-V Nested VMs back to their initial settings correct?

0 Votes 0 ·

@SamecBrianD-1158 No worries! I want to say that reset should also reset nested VMs but I'll need to do some additional research before I can confirm that. I'll get back to you with a more concrete answer.

0 Votes 0 ·

@SamecBrianD-1158 , I think you would have to write a custom PowerShell script to run on the Lab services VM to merge the checkpoint back to what it initially was for all the nested VM to bring them to original state . So in a nutshell the script would :-

  • Create a checkpoint for all the nested VMs within the HyperV in Azure Lab services VM created by the lab instructor.

  • Setup a local Group policy which would merge the original checkpoint for all the nested VMs for every session logout.

  • The policy would run the PowerShell script at every logout to make sure the VMs checkpoints are merged to original state at every time the student logs out .

  • If this isn't ideal then you can let student decide when they are done and run the script before logout .

On how to write the script , please check this article by one of our cloud advocates Thomas .

Hope this helps.

0 Votes 0 ·

@SamecBrianD-1158 , Please use the article https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789196(v=ws.11) to understand more on how to setup the logout script using group policy on the local machine.

Make sure that the nested VMs are all in shutdown state before restoring the old checkpoint . This logic needs to be baked in the script.

Hope this helps your issue and in case you have any further queries , please let us know and we will be happy to help .

Thank you.

0 Votes 0 ·
SamecBrianD-1158 avatar image
0 Votes"
SamecBrianD-1158 answered kobulloc-MSFT edited

Out of curiousity....if the Azure Lab VM was set to start at a checkpoint, where Hyper-V was configured with VMs in a certain setup inside the Azure Lab VM, when I reset the VM, why wouldnt it just set the Hyper-V VMs and settings back to where they were at start? The Hyper-V install is part of the OS, so I would think it would set itself back to how it was when the whole VM was reset.

But apparently not?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Nested virtualization scenarios I'm less familiar with so I'm working to get a better explanation for you.
While I'm doing that, there are two good resources to help visualize what is going on:

106343-image.png

106249-image.png


0 Votes 0 ·
image.png (148.8 KiB)
image.png (191.1 KiB)