To understand whether the role instance is running in the Windows Azure environment you simply need to check this static variable:
RoleEnvironment.IsAvailable
Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)