Skip to content

Instantly share code, notes, and snippets.

@SyntaxC4
Created September 29, 2012 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SyntaxC4/3803254 to your computer and use it in GitHub Desktop.
Save SyntaxC4/3803254 to your computer and use it in GitHub Desktop.
Windows Azure Cloud Service or Web Site: Where am I Deployed?
switch (process.env.WhereAmI.toLowerCase())
{
case "cloud":
//...
break;
case "websites":
//...
break;
case "local":
//...
break;
}
var appSettings = System.Configuration.ConfigurationManager.AppSettings;
var whereAmI = appSettings["WhereAmI"];
switch(whereAmI)
{
case "local":
goto default; // make local as the default action
break;
case "websites":
//...
break;
case "cloud":
//...
break;
default:
//...
}
<?php
switch (strtolower(getenv('WhereAmI')))
{
case "cloud":
//...
break;
case "websites":
//...
break;
case "local":
//...
break;
}
?>
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole1">
<Runtime>
<Environment>
<Variable name="WhereAmI" value="cloud" />
</Environment>
</Runtime>
</WebRole>
</ServiceDefinition>
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="Replace">
<add key="WhereAmI" value"cloud" />
</appSettings>
<!-- //... -->
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="WhereAmI" value"websites" />
</appSettings>
<!-- //... -->
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="Replace">
<add key="WhereAmI" value"local" />
</appSettings>
<!-- //... -->
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="Replace">
<add key="WhereAmI" value"websites" />
</appSettings>
<!-- //... -->
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment