1

I have a standard .Net Framework Asp.Net application deployed in an Azure App Service. Within the Azure configuration, I've set up a couple environment variables and a connection string.

I'm able to retrieve the environment variables correctly at runtime.

var value = System.Environment.GetEnvironmentVariable("AppSettingTest");

How do you I retrieve the connection string?

This application IS NOT Asp.Net Core. I am not using dependency injection and a startup class. I could store that value in an environment variable, but I'm led to believe connection strings stored in the App Service configuration connection string is more secure.

JohnB
  • 3,921
  • 8
  • 49
  • 99
  • 2
    Environment variables in Azure App Service are prefixed with `APPSETTING_`, `SQLCONNSTR_`, etc. You can find the [full list here](https://learn.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet#variable-prefixes) – Andrew Williamson Feb 08 '22 at 19:11
  • @AndrewWilliamson - Spot on, works like a charm, thx. – JohnB Feb 08 '22 at 22:36
  • Does this answer your question? [How do i use azure app service env variables inside my application?](https://stackoverflow.com/questions/56949224/how-do-i-use-azure-app-service-env-variables-inside-my-application) – Andrew Williamson Feb 09 '22 at 00:19
  • @AndrewWilliamson - Yes it does, see previous comment. – JohnB Feb 09 '22 at 00:36
  • Sorry, that comment was added automatically when I marked this as a duplicate – Andrew Williamson Feb 09 '22 at 01:06

1 Answers1

1

Thank you Andrew Williamson and JohnB posting your discussions as answer to help other community members.

Environmental variables in Azure App Service are prefixed with APPSETTING_, SQLCONNSTR_, etc. complete list is available here full list here

Madhuraj Vadde
  • 1,099
  • 1
  • 5
  • 13