How to deploy a solution with two projects to Azur

2019-03-15 21:41发布

问题:

I am trying to minimize the cost of running my web app in Azure App Service. I have a Visual Studio 2017 solution with two Web Projects: Web and API (both .NET Core). The entire solution is part of a single GitHub Repo. Before adding the API project, the build and deployment to Azure App Service was automated. My goal is to deploy both projects under the same App Service (to minimize cost) with two subdomains (e.g. www.example.com and api.example.com) and keep everything automated.

Is this something that can be done? Can somebody please help me understand how this can be done? Can those settings be commited?

回答1:

An Azure App Service Plan can contain multiple web apps. Normally when you use the Azure portal to connect it to source control, Kudu (the tool behind App Service Plans), will create a deployment script for that site.

In case you want to deploy two projects of a single solution (and git repo) to different Web Apps you have to do the following:

  • Create two web apps under the same App Service Plan
  • Connect both of them to the same git repo for automated deployments
  • Modify the deployment parameters

I'm going to suppose you know how to do the first two steps.

To modify the deployment parameters, you could either modify the deployment script by downloading it through Kudu and adapting it or, much simpler, configure it through the portal:

  • Go the App1 => Application Settings => Add setting PROJECT with value <path>\<path-to-app1>.csproj
  • Go the App2 => Application Settings => Add setting PROJECT with value <path>\<path-to-app2>.csproj

Every time you push up a change, both web apps will receive an update, but they will deploy a different part to the web site.

More information can be found here (see last paragraph): https://github.com/projectkudu/kudu/wiki/Customizing-deployments