Hi @Aashritha Reddeddy ,
AFAIK currently there is no direct way to fetch the unused resources for last N days. If interested, you may share it here as feedback. In general, Azure product or feature team would check feasibility of a feature request, prioritize against existing feature backlog, add in roadmap as appropriate and would announce and/or update the related Azure document once a feature request is addressed.
As a workaround, with the features that are currently available, you may leverage Activity logs and Resource Graph Explorer to accomplish this requirement i.e., configure to get the activity logs in Log Analytics workspace and then query the AzureActivity kusto table as shown below.
AzureActivity
| where TimeGenerated >= ago(14d)
| where _ResourceId contains "Microsoft.Compute/disks" or _ResourceId contains "Microsoft.Compute/virtualMachines"
| distinct _ResourceId
Then query the Resource Graph Explorer with the help of resources table as shown below.
resources
| where type == "microsoft.compute/virtualmachines" or type == "microsoft.compute/disks"
Compare the output of AzureActivity table with that of resources table and the difference can be considered as unused resources for more than 14 days.