Start service on newly created VM from captured image

Eusebiu Marcu 201 Reputation points
2020-05-14T06:34:37.433+00:00

Hello,

I've created a VM (Windows) and I've registered a Windows Service (dotnet core 3.1) and marked it as Automatic.

After I capture that VM (because I want to create new VMs from that image, e.g. using Azure API) and create a new VM instance, the service I registered is stopped when the VM is booted.

How can I make that service start with the VM?

Thanks!

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,119 questions
0 comments No comments
{count} votes

Accepted answer
  1. Eusebiu Marcu 201 Reputation points
    2020-06-07T11:43:36.61+00:00

    So, I moved from Image creation to Disk snapshot and create a VM from a copied disk from snapshot.
    I've also increased the time for service start timeout (I had a 1 vCPU and 2GB of RAM)
    https://www.codetwo.com/kb/how-to-extend-the-timeout-for-services-if-they-do-fail-to-start/#:~:text=Run%20Windows%20Services%20manager%20(launch,)%2C%20as%20shown%20in%20Fig.

    Other option: Automatic (Delay start).

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. TravisCragg-MSFT 5,676 Reputation points Microsoft Employee
    2020-05-20T03:19:49.73+00:00

    This should work, did you make sure the original image kept the service after a reboot? Sometimes dependencies or other factors can prevent the service from starting.

    You can also use a custom script extension (easy) or Desired State Configuration (complicated) to configure the service to start on creation.