One of the big problem with cloud providers (AWS, Azure etc) does not provide console login to the server. If sshd does not start at boot time then you are in big trouble!
Luckily, Azure support team told me about Azure linux extension to run a script on virtual machine as root.
Here is the very comprehensive article about this extension;
Unfortunately, there is not way to get a output of the executed commands. Maybe you can send the output outside of the server via curl,ftp or email 🙂