Hi there,
If you need to get the data from the Azure VM only, just register your VM as a Hybrid Worsker Server. And run the script in HRW server instead of Azure Sandbox with a private link (it's a good approach for enterprise-scaled solutions, but not for your scenario imho)
https://learn.microsoft.com/en-us/azure/automation/extension-based-hybrid-runbook-worker-install?tabs=windows%2Carm-template
https://learn.microsoft.com/en-us/azure/automation/automation-hybrid-runbook-worker