Hi Dağhan Karahan,
To retrieve historical compute utilization data for Azure Virtual Machines beyond the default retention period, you can use a combination of Azure Monitor, Log Analytics, and Azure Storage.
Export metrics to an Azure Storage account for long-term retention, you can query or retrieve the data programmatically.
Create a Storage account, add a diagnostic setting to export metrics to your storage account and select the metrics you want to export. For detailed information: Export Metrics to Storage
Use Azure Storage SDKs, Azure CLI, or Azure PowerShell to retrieve the historical data from the storage account.
Azure Log Analytics can collect and store performance data (e.g., CPU, memory) from your VMs for extended periods. You can query this data using Kusto Query Language (KQL).
Enable Azure Monitor for VMs, which will start collecting performance data and sending it to a Log Analytics workspace. For reference: Enable Azure Monitor for VMs
Use KQL to query performance data in Log Analytics. Log Analytics Query Language (KQL)
Log Analytics allows you to configure data retention for up to two years. Data Retention in Log Analytics
You can use the Azure Monitor REST API to programmatically retrieve historical metrics data. Please refer to Azure Monitor REST API Filter
If you have any further queries, let me know. If the answer is helpful, please click Upvote on it.