Simple question, hopefully a simple answer :)
How to I get the app service name, displayed as "test-webapp" in the picture below, from code (C#)? (any other identifier of a specific app service also works).
I have multiple app services, running same code. So I want to be able to express
if(appServiceName == "test-webapp")
{
//take a specific value from web.config and run with it
}
Azure App Service is an HTTP-based service for hosting web applications, REST APIs, and mobile back ends. You can develop in your favorite language, be it . NET, . NET Core, Java, Ruby, Node. js, PHP, or Python.
In the Azure portal, search for and select App services and select the app that you want to move. From the left menu, select Change App Service plan. In the App Service plan dropdown, select an existing plan to move the app to.
An App Service plan defines a set of compute resources for a web app to run. These compute resources are analogous to the server farm in conventional web hosting. One or more apps can be configured to run on the same computing resources (or in the same App Service plan).
You can get it from the WEBSITE_SITE_NAME
environment variable.
To get the variable, use something like:
string siteName = System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME")
You can see a list of environment variables available here: https://github.com/projectkudu/kudu/wiki/Azure-runtime-environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With