Virtual Machine Temporary Storage always cleaned after scheduled start/stop v2

Sébastien Perin 36 Reputation points
2023-01-31T11:22:22.0666667+00:00

I use the Start/Stop VMs v2 to schedule the start and stop of my GPU Virtual machine on a daily basis.

My concern is about the Temporary Storage disk which is cleaned after each scheduled stop and start. I use this disk to store some cache data of my application, so I can accept the Temporary Storage disk to be cleaned sometimes, but not every day.

However as stated in the documentation of the managed disks of a virtual machine:

During a successful standard reboot of the VM, data on the temporary disk will persist.

That's right, because if I manually reboot the VM, then the Temporary Storage does not get cleaned. I suspect the Temporary Storage disk is cleaned after a scheduled start/stop v2 because the VM is deallocated after the scheduled stop.

Is that right? If yes, then how I could workaround this? May I configure the scheduled stop to not deallocate the VM?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,566 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,472 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
590 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bjoern Peters 8,856 Reputation points
    2023-01-31T12:02:12.5966667+00:00

    Hi Sebastien,

    Why are you using that Start/Stop script? To reboot your VM or to save money by stopping the VM during the night?

    If it is the cost-saving aspect, then you are doing it right, BUT you have to live with the "refresh" of the temporary drive because this is the expected behavior.

    Your understanding of that process is correct. The shutdown initiates the deallocation of those discs.

    The easiest and fastest way to keep your cache => add another (small) data disc to the VM and reconfigure your app to use the new disc as a cache location.
    Or another option might be... create a PowerShell script that runs before the shutdown and makes a copy/backup of those cache folders to the C-drive... on startup, move those folders back to the temporary drive.

    I hope my answer is helpful to you,

    Your

    Bjoern Peters

    If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sébastien Perin 36 Reputation points
    2023-01-31T12:20:04.7633333+00:00

    Thanks @Bjoern Peters

    Yes I use Start/Stop v2 automation to save money during night. Too bad there's no cool option to keep the temporary storage content of the VM in my scenario.

    I can handle the application cache on the C-Drive too, or indeed add a dedicated data disk as you suggested. The second alternative you suggested is also interessting.

    Would you please know a good way to execute a script before an azure VM shutdown (by using automation, or an azure VM configuration settings)? Or should I directly rely on Windows Local Group Policy as suggested here?