Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How and where to define an environment variable on Azure

I have an ASP.NET MVC web application deployed to Azure. I'm reading my setting using the GetEnvironmentVariable(...) method.

The problem is that I can't find a way to define this environment variable in Azure Portal. Where can I do that?

I don't want to have this stuff in a file. Data that will be there are credentials.

like image 984
Jaroslaw Stadnicki Avatar asked Jan 05 '16 09:01

Jaroslaw Stadnicki


People also ask

How do I set environment variables in Azure?

To set environment variables when you start a container in the Azure portal, specify them in the Advanced page when you create the container. Under Environment variables, enter NumWords with a value of 5 for the first variable, and enter MinLength with a value of 8 for the second variable.

Where do we set environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.


1 Answers

I assume you are using Azure App Service (formerly known as Azure Websites).

To define your own environment variable, click to your site → All SettingsApplication settings:

Enter image description here

Add an app setting in the "App settings" section:

Enter image description here

You can verify the value from the debug console.

Going to https://{your site name}.scm.azurewebsites.net/DebugConsole:

Enter image description here

like image 70
Xiaomin Wu Avatar answered Oct 13 '22 23:10

Xiaomin Wu