title: Azure Function – Current Azure Resource Name
body: <p>If I am in an Azure Function that is a TimerTrigger how can I get the name of my deployed Azure Resource at runtime.</p>
  
  <p>In an HttpTrigger you can simply do this:  <code>req.RequestUri.AbsoluteUri</code> and get something that gives a good "<em>as deployed</em>" runtime description.</p>
  
  <p>In a Timer it is not as obvious as to how you would get your Azure Resource Name or Path while the TimerFuncton is executing.</p>
  
  <p>I would like something similar to   Microsoft.Azure.WebJobs.ExecutionContext which gives you the compile time Function info – but I am looking for some run-time info from the Running Azure Resource that is executing my TimerTrigger function.</p>
  
  <p>My fallback is to HardCode my Azure Resource Name into an Environment variable and read that at run-time. Seems odd but will work.</p>
  
  <p>Thank You Claudiu</p>
  
  <p><strong>Here are some final notes about this:</strong></p>
  
  <pre><code>// Environment Variable Usage 
  string res = System.Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME", EnvironmentVariableTarget.Process);
  //  WEBSITE_HOSTNAME is like "myAzureDeployedFuncName.azurewebsites.net" 
  //  WEBSITE_HOSTNAME is like "localhost:7072" 
  string res = System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME", EnvironmentVariableTarget.Process);
  //  WEBSITE_SITE_NAME is "myAzureDeployedFuncName" on Azure 
  //  WEBSITE_SITE_NAME is not there in local debug function runtime 
  
  // using AppSettings is not the same and usign the above GetEnvironmentVariable call 
  string res = System.Configuration.ConfigurationManager.AppSettings["WEBSITE_HOSTNAME"]; // not there for Settings interface
  //  WEBSITE_HOSTNAME will be blank - it is not part of "Settings"
  string res = System.Configuration.ConfigurationManager.AppSettings["WEBSITE_SITE_NAME"]; 
  //  WEBSITE_SITE_NAME is "myAzureDeployedFuncName" on Azure when using "settings" instead of Environment variable 
  //  WEBSITE_SITE_NAME is not there in local debug function runtime 
  // the above AppSettings are not the same as GetEnvironmentVariable behavior at runtime 
  </code></pre>
  
  <p><strong>To Call "yourself" from a function app timer trigger this is what is useful ...</strong></p>
  
  <p>WEBSITE_HOSTNAME =  myAzureDeployedFuncName.azurewebsites.net</p>
  
  <pre><code>Some Other potentially useful Env Vars:
  // next one has scm in name
  HTTP_HOST = myAzureDeployedFuncName.scm.azurewebsites.net
  // slot help
  APPSETTING_WEBSITE_SLOT_NAME = Production
  </code></pre>