I used Windows Task Scheduler to automate the Python scripts to run between 9:20 pm and 11:00 pm. It wouldn't make sense to keep the server (Azure VM) running all day. So I set up an automation on Azure to start up the server at 9:00 pm and shut it down by midnight. Below are the steps to doing this.
If you run a search online, you will come across multiple ways to doing this. Some require you writing Powershell scripts. The method I am going to illustrate is the least error prone and most straightforward way I have come across.
Step 1: Log into your Azure account portal
Click on Create a resource.
Step 2: Search for Automation
Click on Automation.
Step 3: Create a new Automation
Step 4: Complete the Automation Account Creation
Make sure to tick use existing resource group, and pick the resource group of the VM you want to auto shutdown/startup. Also best to match the location selection.
Step 5: Add Startup and Shutdown Runbooks to the Automation Account
Select the automation account you just created.
Select Runbook under Process Automation. And click on Browse gallery. This allows you to create the startup and shutdown automation runbooks.
Click on Edit in the created Runbook
Then publish the runbook.
Click on Schedule after publishing.
Set the Time to run the Start VM runbook by clicking on "Link a Schedule to your runbook"
Lastly, set the parameters which will link it to the VM you want to control. Make sure you match the resource group and VM name. You can leave the AzureConnectionAssetName blank so the default is used.
Now you repeat same steps for Shutdown runbook after picking from the runbook gallery.
Step 6: Sit back and watch the automation runbooks do their work
You can monitor the runbook activities from Jobs in the Runbook Overview.
And that's all!
If you're craving chinese
ReplyDeletefood delivery, I highly recommend checking out Only-Halal.com! They offer a wide variety of delicious and authentic Chinese dishes that are all 100% halal. The delivery is quick, and the food always arrives fresh and flavorful. It’s the perfect choice for anyone looking for halal Chinese food delivered right to their doorstep!