Base solution for your next web application
Open Closed

Angular - environments #8717


User avatar
0
BobIngham created

This is one for @ismcagdas. I'm currently on 6.8.0, way behind the curve but,hey-ho, maybe the current crisis will now give me time to upgrade before we go to market. In the meantime I'm having to keep and then upload angular appconfig.production.json files to each of my testing, staging and production environments. I then restart the service (Azure) to pick up the new environment file which is especially annoying when swapping my staging slot for my production slot. There was some work carried out post-6.8.0 on environments in the Angular solution. Can you point me in the right direction so I can implement same in my 6.8.0 solution?


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @bobingham

    For upgrading, I suggest you to wait for 8.5 because we wil upgrade to Angular 9 and there will be some changes. For Angular environment, we haven't done anything related to this problem. The easiest way I can think is, you can write a Javascript code in index.html and it can write version of the app to local storage. Then, it can compare current version with the user's version and automatically refreshes the page if both are not equal. On each refresh, of course, app version in browsers local storage must be updated.

  • User Avatar
    0
    BobIngham created

    Hi @ismcagdas, are we talking at cross-purposes? I'm talking about the appconfig.json/appconfig.production.json/appconfig.staging.json - picking these up from site environment variables.

    Is there some code which is telling the system whether to use appconfig.json or appconfig.production.json?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sorry, I got it wrong. Related appsetting.json files are defined in https://github.com/aspnetzero/aspnet-zero-core/tree/dev/angular/src/environments

  • User Avatar
    0
    BobIngham created

    Hi @ismcagdas, Thanks for that. I need to work out the plumbing to plug it into 6.8.0. Are you following the same methodology as this Environment Variables in Angular?

  • User Avatar
    1
    BobIngham created

    Hi @ismcagdas, I believe I'm going about this the wrong way. I was trying to set up environment variables for the angular project similar to those which exist in the .NET Core project. In Azure these app settings don't follow swaps between deployment slots in .NET Core. Thus my production environment always reads appsettings.production.json, my staging slot reads appsettings.staging.json and my testing slot reads appsettings.testing.json and a variable is set in each slot for ASPNETCORE_ENVIRONMENT (production, staging, testing) so these settings don't switch between slots. I'm banging my head against the wall trying to get angular to work in the same way and I'm obviously going about it the wrong way. I need to do some research on how to swap between slots with an angular project, maybe I have to build a pipeline in DevOps. I will close this for now and thank you for your help and when I find the answer and someone finds this thread they can try re-open and ask me how I did it! Cheers.