Hello, @VENKATARAMANA CHAKRAVARTHULA !
How do I restore an accidentally deleted VM?
If you have a backup or a snapshot of the VM, then you can restore the VM:
https://learn.microsoft.com/en-us/azure/backup/backup-azure-arm-restore-vms
If you did not backup or create a snapshot of the VM and disks have been deleted, then unfortunately the VM has been permanently deleted.
How can I prevent this from happening in the future?
There are several options you can take advantage of to make sure you don't end up in this situation :
- Lock your resources to protect your infrastructure : Using a lock like
CanNotDelete
will prevent the resource/VM from being accidentally deleted.
- Azure Backup: Azure backups can be created through the Azure portal. This method provides a browser-based user interface to create and configure Azure backups and all related resources.
- Soft delete for Azure Backup: With soft delete, even if a malicious actor deletes a backup (or backup data is accidentally deleted), the backup data is retained for 14 additional days, allowing the recovery of that backup item with no data loss.
- Azure Disk Backup : Azure Disk Backup is a native, cloud-based backup solution that protects your data in managed disks. It's a simple, secure, and cost-effective solution that enables you to configure protection for managed disks in a few steps. It assures that you can recover your data in a disaster scenario.
- Selective disk backup and restore for Azure virtual machines : Azure Backup supports backing up all the disks (operating system and data) in a VM together using the virtual machine backup solution. Now, using the selective disks backup and restore functionality, you can back up a subset of the data disks in a VM. This provides an efficient and cost-effective solution for your backup and restore needs.
I hope this has been helpful! Your feedback is important so please take a moment to accept answers.
If you still have questions, please let us know what is needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!