To my knowledge there is a not a good way to determine this. I like the trick that you have, but it does seem like a poor workaround. Another thing that you can try to check the version of the Azure Agent in the VM, depending upon when the images were downloaded, Azure Stack should use a past version of the agent.
Identify if VM is running on Azure Cloud or Azure Stack Hub
I need to identify if a VM is running on Azure cloud or Azure stack hub.
MSFT documentation says that the IMDS service is not available on Azure Stack Hub VMs. Call to IMDS on Azure Stack Hub VM returns 500 error code and message {"Message":"Error in config data"}. It does not return 404.
Azure Cloud documentation says that IMDS can return 500 error code on Azure Cloud VMs
https://video2.skills-academy.com/en-us/azure/virtual-machines/windows/instance-metadata-service#errors-and-debugging
Can someone please confirm if we need to rely on error code i.e. 500 and error message "Error in config data" both to know if a VM is running on AZS?
Is there any other way ?
Best regards,
Sachin
1 answer
Sort by: Most helpful
-
TravisCragg-MSFT 5,681 Reputation points Microsoft Employee
2020-12-04T02:28:49.863+00:00