r3plica
r3plica

Reputation: 13367

.net core, angular and application settings

We currently have our API set up in azure and use deployment slots which each have their own app settings. For example, on our live slot we set our connection string to the live database. On our dev slot we set the connection string to the test database.

So, I have been tasked with doing something similar with our SPA. I created it using .net core and angular. Currently it has a constant set up:

.constant('apiUrl', 'https://ourlive.api.com')

I have a few set up and I just comment out the ones I am not using. What I have been tasked with, is putting these into the application settings and using deployment slots for different URLs. For example, the live slot will use the Live URL and the Dev slot will use the Dev URL.

I read that you can do this using npm but this isn't an option for us because we are using .net and the npm doesn't seem to work like that. Is there another way we can read the application settings?

Upvotes: 1

Views: 607

Answers (1)

Gary Liu
Gary Liu

Reputation: 13918

Per my understanding, your scenario is a purely HTML + angularjs SPA, although they are running in a .NET core runtime. And your requirement is that you want to get the slot application settings in your SPA application. If I have any misunderstanding about your structure, please feel free to let me know.

You can try to leverage the .net core runtime to get the application settings in slot, and expose as an RESTful API for your SPA application.

And in your SPA application, you can create a server, to call your .net core's API, and you can inject this server and call this api when your SPA bootstrap in and keep the settings in $rootscope for your entire SPA application.

For slot application settings, you can refer to https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-staged-publishing#configuration-for-deployment-slots for more info.

Upvotes: 1

Related Questions