Thanks for posting your question in the Microsoft Q&A forum.
Try the following steps
- Ensure your VM has adequate CPU, memory, and disk space for the operations you're performing. Consider upgrading to a larger VM size if necessary.
- Confirm that the NSG associated with your VM allows inbound traffic on port 22 for SSH and any other required ports.
- Use Azure's boot diagnostics and serial console to check for any boot-related issues or error messages that might explain the VM's instability.
- Try manually updating or reinstalling the Azure Linux Agent on the VM to ensure proper communication with Azure services.
- Instead of manually installing software after connecting via SSH, consider using Azure's custom script extension to automate the installation process.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful