Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Azure Web App name in code

Is there any way to obtain the name of the web app from within code. i.e. if I have deployed my app to a web app called my-webapp-dev-ne I need to be able to get this name in code. The reason I cannot add it to an app config file or any other method is that the same app can be deployed to multiple places.

like image 661
Ken Cowley Avatar asked Sep 25 '15 07:09

Ken Cowley


People also ask

How do I get Azure app name?

Select Azure Active Directory. Select App registrations. Select New registration. Name the application, for example "example-app".

What is app name in Azure?

This is the name of your application in Azure. This will eventually turn into the URL for your application. For example, if my App Name is 'thingy123' application URL that azure generates will be https://thingy123.azurewebsites.net. {{Resource Group}} This is the name of the Azure resource group.

How do I download an Azure web app code?

Just expand the “site” directory and right click the “repository” folder to download it. Now, navigate to the repository folder and you will see your source code! That is it. You now have the source code of your project back in your possession.


2 Answers

Adding to Rick's answer, you can find more informative environment settings here

  • WEBSITE_SKU - The sku of the site (Possible values: Free, Shared, Basic, Standard).
  • WEBSITE_COMPUTE_MODE - Specifies whether website is on a dedicated or shared VM/s (Possible values: Shared, Dedicated).
  • WEBSITE_SITE_MODE - The mode for the site (can be Limited for a free site, Basic for a shared site or empty for a standard site).
  • WEBSITE_HOSTNAME - The Azure Website's primary host name for the site (For example: site.azurewebsites.net). Note that custom hostnames are not accounted for here.
  • WEBSITE_INSTANCE_ID - The id representing the VM that the site is running on (If site runs on multiple instances, each instance will have a different id).
  • WEBSITE_NODE_DEFAULT_VERSION - The default node version this website is using.
  • WEBSOCKET_CONCURRENT_REQUEST_LIMIT - The limit for websocket's concurrent requests.
like image 101
Amit Apple Avatar answered Nov 03 '22 00:11

Amit Apple


The web app environment provides an environment variable called WEBSITE_SITE_NAME that contains the name. You can access it from C# code like this.

var siteName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME");
like image 43
Rick Rainey Avatar answered Nov 03 '22 01:11

Rick Rainey