The Azure Instance Metadata service is available from within an Azure VM and can be used to access information about the Azure VM without needing to connect to Azure.
The URL to access this service is
Invoke-RestMethod -Headers @{“Metadata”=”true”} -Method GET -NoProxy -Uri “http://169.254.169.254/metadata/instance?api-version=2021-02-01”
Further information is available from Azure Instance Metadata Service for virtual machines – Azure Virtual Machines | Microsoft Learn