You can use a data ingestion service like log analytics - https://learn.microsoft.com/en-us/azure/azure-monitor/agents/log-analytics-agent#install-and-configure-agent
to collect performance data - https://learn.microsoft.com/en-us/azure/azure-monitor/agents/data-sources-performance-counters
This data can be retained for up to 2 years and you can query the logs even if the VMs are deleted.