The cheapest way (spot) to use Azure servers, there will be a minimum of 90% off

You need to be prepared to forcibly interrupt the server 0-3 times a month for about five minutes each time. You must accept it and cannot avoid it.

Three billing and booting methods:

  1. Original price, no discount
  2. Commitment to X years, monthly payment, similar to monthly subscription, about 60% off
  3. ready-made (preemption, SPOT), 10% off

The IP will change after being closed, please set up DDNS yourself or use the DDNS that comes with Azure

The startup aspect is the same, that is, one more tick is required, so that most configurations will be discounted (90%OFF), and the availability zone must select “No infrastructure redundancy required”.

These are all normal, but the problem is how to make it restart automatically after being interrupted by the system.

Search for “Automation Accounts” in the search bar and create it. You must ensure that you are in the same subscription as the virtual machine. The region is not sensitive. The other next steps are until creation.

Then open the automation account you created, and open the Identification tab. At this time, “System Assignment” should have been opened and the object ID will be displayed. If not, turn it on manually.

Copy the “Object Principal (ID) given to you, open your subscription, Access Control → Add → Add Role Assignment”

Select the automation account you created for the managed identity, add it, and give the entire subscription permission to automation. Review and assign, authorization complete.

Go back to automation, select Runbook, import Runbook, and pay attention to the same selection.

The PowerShell file to import into the runbook is here: start.ps1

Select the imported runbook, click edit and publish, you don’t need to modify anything.

Now that the pre-set has been completed, start to set the monitoring of automatic power-on after shutdown

Select your SPOT virtual machine and label it.
Tags may or may not be unique. For example, if several virtual machines use the same label, all the virtual machines with the same label will be started at the same time.

Select (Monitoring, Alerting) below and start creating alert rules.

Don’t look at the dropdown, just select “See all signals” and search for “VM Availability Metric (Preview)”.

Copy my condition, which means, check every minute, if the virtual machine is less than 1 available (indicating it is shut down), then an alarm will be triggered. Now it’s just a trigger, and there are still operations to be set later.

Then create an operation group in the next step. Note that it must be in the same subscription as your server, and cross-subscriptions are not allowed.

Can even send you a text message telling you that the server is down.

Then start to set the boot operation, select the runbook I gave you, in my case, the name I set is “start”.

Set the parameters, fill in “Start” in the first box, fill in the first one of the label you put on the server in the second box (see above, I filled in ‘spottagstags’), and fill in the label you put on the server in the third box The second one (see above I filled in 111).

Review and create, well, the action group is created. Go back to the upper layer of alarm rules and select the action group you just created. Then set a name for your alarm rule. Then create, now the whole process is complete.

Now you can test it by yourself, first shut down the server yourself, after a while, a new alert will appear in your alert, and then your server will start up, it will take less than 5 minutes.

According to the current capacity of Azure, it is shut down about once every 1-2 months.

Leave a Reply

Your email address will not be published. Required fields are marked *