Score:0

Is it possible to schedule a destruction of an Azure VM?

jp flag

I deployed a spot VM on Azure, using an ephemeral OS Disk.

I also defined a Microsoft.DevTestLab/schedules resource with the hope to automatically shutdown (and so, in my case, destroy), the VM automatically:

resource autoShutdownConfig 'Microsoft.DevTestLab/schedules@2018-09-15' = {
  name: 'shutdown-computevm-${vmName}'
  tags: mytags
  location: location
  properties: {
    status: 'Enabled'

    dailyRecurrence: {
      time: '02:00'
    }
    timeZoneId: 'UTC'
    taskType: 'ComputeVmShutdownTask'
    targetResourceId: vm.id
  }
}

However the shutdown task did not happen (instead I had an error in the activity log, at the time the task ran:)

Operation 'deallocate' is not supported for VMs or VM Scale Set instances using an ephemeral OS disk.

I would like to know

  • what values are available for taskType for a Microsoft.DevTestLab/schedules resource
  • if there is a taskType that can be used to destroy the VM at a specific time.

Thanks

Score:0
ng flag

As far as I know Dev Test Lab schedules don't support destroying VM's, and as you saw you can't stop a VM/VMSS with an ephemeral disk you can only destroy it.

You could use Azure Automation to create a script that destroys the VM at a specific time. You would just need to write some azure PowerShell using the remove-azvm command and then attach a schedule to the job to run at a specific time.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.