Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function app equivalent for IHostingEnvironment.IsDevelopment()

In asp.net core Startup.cs Configure we are provided an IHostingEnvironment env parameter that exposes an env.IsDevelopment() call to determine if you are currently running in a visual studio f5 debug session or a cloud deployment scenario. In function app is there a story for determining this same thing so you can write code that only runs during f5 debug session, e.g. a populated (. . ., ClaimsPrincipal principal) dependency injected parameter where this is only normally assigned claims and roles when deployed into cloud EasyAuth enabled environment.

like image 889
myusrn Avatar asked Dec 08 '18 23:12

myusrn


1 Answers

IHostingEnvironment.IsDevelopment() actually checks whether the ASPNETCORE_ENVIRONMENT environment variable is set to "Development". If that's what you want to do then you can use Environment.GetEnvironmentVariable() to check the value. However, to determine specifically if you're in an F5 debug session you should check Debugger.IsAttached instead.

like image 157
MarkXA Avatar answered Nov 11 '22 17:11

MarkXA