How to turnoff azure internally?

kr flag

We have a build machine which takes 3 to 4 hours to do the build process. So, earlier it is in aws, so kept lambda to turnon during early morning and after 4 or 5 hours, the last step of build command is to send an email and turnoff the machine.

But, now we migrated to azure. If we kept the same shutdown command here, the machine is getting shutdown but as per azure documentation, there is difference in shutdown command and turnoff using azure portal.As the billing will continue even the machine is shutdown.

How to setup this poweroff internally so that if any command ran inside the machine should reflect the turnoff in the azure portal.

ng flag

You can't deallocate (the term for turning off and no longer being charged) a machine from inside the VM, you need to talk to the Azure API to do this. The simplest way would be to have your build process trigger an Azure Function or Azure Automation Job that runs some Azure PowerShell that runs the Stop-AzVm command against that VM.


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.