How to determine if an asp.net app is running on an azure vm

263 Views Asked by At

We have an asp.net app that gets deployed to both On-Prem and on Azure VMs. We are trying to figure out how to configure the app so that when deployed on an Azure VM it will use Azure App Configuration Service, but when deployed On-Prem it will continue to use the settings in the config files?

How can we know on app start up whether or not we are deployed on an Azure VM?

1

There are 1 best solutions below

0
On

If you can, I would recommend you add a special environment variable when you provision your Azure VM or deploy your application. If not, you may use Azure Instance Metadata Service to tell the code is running in Azure VMs.