Используя SDK 2.2, я все еще не мог найти лучшего и более надежного решения, чем полагаться на имя роли.
public static bool IsWebRole()
{
var roleName = RoleEnvironment.CurrentRoleInstance.Role.Name;
var match = Regex.Match(roleName, ".*webrole.*?", RegexOptions.IgnoreCase);
if (match.Success) return true;
match = Regex.Match(roleName, ".*workerrole.*?", RegexOptions.IgnoreCase);
if (match.Success) return false;
throw new Exception(String.Format("Can't figure out role type of {0}", roleName));
}