Automated starting of processes in a sequence post Azure windows server reboot.

nikhil satpute 2 Reputation points
2022-11-27T17:02:54.147+00:00

Hi experts,

Good day!!

We have an Azure VM running windows 2016 OS Which runs a specific BigHand Application. It has a pre-requisite that whenever the Machines fresh starts or reboots, the BigHand Services should start in a specific sequence or else the Services get stuck and will not be able to contact the SQL Database server.

For patching the VMs, we have enabled Update management using Azure Automation Account. Schedule is set to 'Reboot if Required' post patching.

Can we set a runbook or automated script to trigger defining the Services and its sequence during start-up of the Machine, so it can be run whenever there is a reboot post patching.

Please advise on this.

Regards,

Nikhil A Satpute

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,184 questions
{count} votes

3 answers

Sort by: Most helpful
  1. TP 83,221 Reputation points
    2022-11-27T17:16:21.29+00:00

    Hi Nikhil,

    How about creating a scheduled task in the VM that is set to run at computer startup, as NT AUTHORITY\SYSTEM, that points to a .cmd file. In the .cmd file you would have several lines of net start <service name>. For example:

    net start FirstService
    net start SecondService
    net start ThirdService

    You should test to make sure it works as you may need to modify to handle special requirements.

    -TP


  2. Maxim Sergeev 6,566 Reputation points Microsoft Employee
    2022-11-28T03:04:37.353+00:00

    Hi there,

    Can we set a runbook or automated script to trigger defining the Services and its sequence during start-up of the Machine, so it can be run whenever there is a reboot post patching.

    Yes, literally, this feature (post-script in Update Management) was designed to solve such scenarios
    Pleas have a look at https://learn.microsoft.com/en-us/azure/automation/update-management/pre-post-scripts


  3. AnuragSingh-MSFT 21,241 Reputation points
    2022-12-11T05:23:27.047+00:00

    @nikhil satpute , thank you for the reply. Please see the link below which contains some sample and concepts for getting the required result using post deployment scripts in Azure Automation

    Sample pre-post script
    update-management-run-script-with-run-command/UpdateManagement-RunCommand.ps1

    The first script contains boilerplate code for authentication using Managed Identity. The second script has a complete script to start a single script, but it uses service principal for authentication. You could mix the concepts from both of them to meet your requirement. It will require some more modification in the $scriptBlock which contains the logic to start the service. I am uploading a sample script to start 2 services in sequence with this reply.

    In the sample script uploaded, the logic to start services in sequence are available in $scriptBlock (line 62-123).

    Hope this helps. Please let us know if you have any questions.