简体   繁体   中英

Configure Angular with ASP.NET Core on Azure App Service

I have a web app with Angular and .NET 5 and I want to host it on 2 different Azure App Service (one for the Test environment and one for Prod).

I have followed the page https://angular.io/guide/build and created the following environments:

  • environment.ts
  • environment.test.ts
  • environment.prod.ts

The web app I'm publishing from Visual Studio from a.pubxml file (I have 2 different ones for each app service).

How can I configure the App Services to use separate Angular environment variables? For example:

App service A -> environment.test.ts

App service B -> environment.prod.ts

I assume there should be some additional changes done to package.json and some to the .NET web project.

Try the below steps if it helps to fix the issue:

  1. In project.json file > publishOptions section > include a new application setting called appsetting.{env}.json .
  2. In the Azure Web Application > Select application settings > Add setting ASPNETCORE_ENVIRONMENT and set it.

For more steps, follow this Configuration with Azure App Services and ASP .NET Core

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM