Hello Liya Zeng,
Please find answers to your questions below:
- How can I safely switch/migrate my current VM to a standard Azure-provided Linux image (without losing data)?
You'll have to unfortunately create a new VM with the expected VM image and then migrate your data from older VM to newer VM and then verify that you have all your data and then delete older VM. - Is there a recommended process (e.g., exporting the disk → redeploying VM with an official image → attaching disk)? Recommended process is to make sure the data is not on your OS disk and move the data to attached disk. If your data is on the attached disk (Not on OS disk) it makes the things easier otherwise it makes complex finding our files from OS disk and move them to attached disk and stop the VM and detach the managed disk and once you have your new VM ready with the new OS you can attach the managed disk later on. Easier process would be to backup your data using AzCopy to an Azure Blob, once your new VM is deployed, you can install AzCopy in your new VM and copy that data back into your new VM. (For detailed guidance on how to use AzCopy, you can refer: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-blobs-upload) You can do the steps in below order:
A) Install AzCopy and copy the required data to an Azure Blob into a storage account.
B) Create a new VM with your required OS. C) SSH into new VM.
D) Install AzCopy and copy the required data from the Azure Blob into your VM.
E) Validate that all your files are with you.
F) Delete older VM. - How can I ensure that future VM deployments only use official Azure images, so I don’t get unexpected Marketplace costs again?
You can put this as best practice for you/your team do the VM deployments, just ensure that you are using the Official Microsoft partner publishers' images to avoid running into this issue. For example, if you want to use Ubuntu use images available by Canonical publisher (only LTS servers). (see: https://ubuntu.com/azure)
If you want to use SUSE Linux server, use images available by SUSE publisher (see: https://azuremarketplace.microsoft.com/en-us/marketplace/apps?search=suse%20enterprise%20linux&page=1&filters=pricing-free)
For RHEL, use images available by Red Hat Inc as Publisher For Debian, use images available by Debian as Publisher.
For Windows images, use images available by Microsoft as Publisher.
Additionally, you can enforce policy over your Subscription such that no Azure VM image uses publisher apart from your recognized ones (such as Microsoft, Canonical, SUSE, Debian, Red Hat Inc, etc) so that you don't get surprised in the end by third party image prices. To know more about policies, please refer: https://learn.microsoft.com/en-in/azure/governance/policy/overview.
Also, keep in check for the Billing over some period of time, set alerts to notify you in order to avoid running into this kind of issue again.