You can do it the old-fashioned way, by looking for the existence of an Environment Variable.
Set the value of your environment variable in computer properties and read it using Environment.GetEnvironmentVariable("MyVariable").
On Azure, the variable won't be present, so the call will return null.