3

I have created an APP using Angular 8 and deployed on Azure as a web app (AppService) on windows OS. I have created an AppSetting called MyAppSetting. When I tried to access the app setting in angular 8 as process.env.APPSETTING_MyAppSetting or process.env.MyAppSetting, it is showing as undefined.

How to access app setting values in Angular 8 deployed on Azure?

James Z
  • 12,209
  • 10
  • 24
  • 44
Dee
  • 183
  • 3
  • 13

1 Answers1

0

wDon't believe this is possible with straight up Angular is a client-side framework. Since it's a frontend framework running in the context of the browser, it doesn't have access to the environment variables on the server. Angular 8 template does include environment.ts that can be used as work around. The following blog posts shows how you can make use of file.

https://medium.com/@zaheeer1/angular-6-compile-time-vs-run-time-environments-180c86c3d2e2 https://www.jvandemo.com/how-to-use-environment-variables-to-configure-your-angular-application-without-a-rebuild/

One option that might work though is server side rendering. I'm no angular expert but https://blog.jeremylikness.com/blog/2018-09-19_serverside-rendering-ssr-with-angular-in.net-core-2.1-part-three/ demonstrates using Angular with Angular Univesral and dotnet core to implement service side rendering.

Ryan Hill
  • 1,821
  • 2
  • 8
  • 21