Azure Cost History data starting in February 2023 is collected directly from Cost Management API.
If the monthly total costs you are viewing in Cost Management do not match with Cost History monthly costs, the reason can be due to how the data is being retrieved in Cost Management. To rule this out, ensure you are retrieving the "actual cost" details instead of "amortized cost" details to fix the cost discrepancy that you are viewing.
Each metric affects how data is shown for your reservation charges.
Actual cost - Shows the purchase as it appears on your bill. For example, if you bought a one-year reservation for $1200 in January, cost analysis shows a $1200 cost in the month of January for the reservation. It doesn't show a reservation cost for other months of the year. If you group your actual costs by VM, then a VM that received the reservation benefit for a given month would have zero cost for the month.
Amortized cost - Shows a reservation purchase split as an amortized cost over the duration of the reservation term. Using the same example above, cost analysis shows a $100 cost for each month throughout the year, if you purchased a one-year reservation for $1200 in January. If you group costs by VM in this example, you'd see cost attributed to each VM that received the reservation benefit.
Reference link: Common cost analysis uses in Cost Management - Microsoft Cost Management | Microsoft Learn