如何将具有两个项目的解决方案部署到Azure App Service? [英] How to deploy a solution with two projects to Azure App Service?

查看:142
本文介绍了如何将具有两个项目的解决方案部署到Azure App Service?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将在Azure App Service中运行Web应用程序的成本降至最低.我有一个包含两个Web项目的Visual Studio 2017解决方案:Web和API(均为.NET Core).整个解决方案是单个GitHub Repo的一部分.在添加API项目之前,将构建和部署到Azure App Service的过程自动化.我的目标是在两个子域(例如www.example.com和api.example.com)的同一个App Service下部署两个项目(以最大程度地降低成本),并使一切保持自动化.

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?

推荐答案

Azure应用服务计划可以包含多个Web应用.通常,当您使用Azure门户将其连接到源代码管理时,Kudu(应用服务计划背后的工具)将为该站点创建一个部署脚本.

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.

如果要将单个解决方案的两个项目(和git repo)部署到不同的Web Apps,则必须执行以下操作:

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:

  • 在相同的应用程序服务计划下创建两个Web应用程序
  • 将它们都连接到同一个git repo以进行自动部署
  • 修改部署参数

我假设您知道如何执行前两个步骤.

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

要修改部署参数,您可以通过通过Kudu下载并修改它来修改部署脚本,或者更简单地说,通过门户对其进行配置:

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:

  • 转到App1 =>应用程序设置=>将设置PROJECT添加为值 <path>\<path-to-app1>.csproj
  • 进入App2 =>应用程序设置=>添加值为<path>\<path-to-app2>.csproj的设置PROJECT
  • 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

每次您进行更改时,两个Web应用程序都会收到更新,但是它们会将不同的部分部署到网站上.

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.

可以在此处找到更多信息(请参阅最后一段): https://github. com/projectkudu/kudu/wiki/Customizing-deployments

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

这篇关于如何将具有两个项目的解决方案部署到Azure App Service?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆