[英]How to host multiple apps on one Azure Web App
i built app (ASP .NET Core MVC + Angular). 我建立了应用程序(ASP .NET Core MVC + Angular)。 I need to deploy this app for three different customers. 我需要为三个不同的客户部署此应用程序。 Each customer at this moment have its own database. 此刻每个客户都有自己的数据库。 Is it possible to have multiple sites inside one azure web app (like mysite.com/a, mysite.com/b and mysite.com/c) and each of these sites to have its own connection string ? 一个Azure Web应用程序中是否可以有多个站点(例如mysite.com/a、mysite.com/b和mysite.com/c),并且每个站点都有自己的连接字符串? Or should I go with path 1 customer - 1 web app ? 还是应该使用路径1客户-1 Web应用程序? Tnx TNX
While there might be a way to have your application deployed to the same App Service. 虽然可能有一种方法可以将您的应用程序部署到同一App Service。 It would definitely involve editing the Kudu build scripts. 肯定会涉及到编辑Kudu构建脚本。 I'm don't know much of the details there to get it working. 我不知道要使它正常工作的很多细节。
However, If you stuck with 1 App Service for each customer, you should be able to set up an environment variable in each App Service with a database connection string for each customer. 但是,如果您为每个客户坚持使用1个App Service,则应该能够在每个App Service中使用每个客户的数据库连接字符串设置环境变量。 By doing this, you could reference that environment variable in your code so you don't have to recompile with a different database connection string for each customer. 这样,您可以在代码中引用该环境变量,因此不必为每个客户使用不同的数据库连接字符串重新编译。 To create an enviroment variable in Azure App Service, go to your app in the Azure Portal. 若要在Azure App Service中创建环境变量,请在Azure门户中转到您的应用程序。 Then, select Application Settings from the side bar. 然后,从侧栏中选择“应用程序设置”。 Scroll down to App Setting Names, and you should be able to create an application setting with the database connection string for each customer in each App Service. 向下滚动到“应用程序设置名称”,您应该能够使用每个应用程序服务中每个客户的数据库连接字符串创建一个应用程序设置。
For more information on how to do that, check out this post on Stack Overflow . 有关如何执行此操作的更多信息,请查看Stack Overflow上的这篇文章。
Another option would be to create an App Service with a new slot for each customer. 另一个选择是为每个客户创建一个带有新广告位的应用服务。 They would all inherit their settings from the master App Service. 他们都将从主应用程序服务继承其设置。 In each child App Service, you would be able to set an application setting that is slotted, which would only be for that slot. 在每个子应用程序服务中,您都可以设置有槽位的应用程序设置,该设置仅适用于该槽位。 However, this is very similar to the previous option in which you create 3 separate App Services. 但是,这与您创建3个单独的App Services的前一个选项非常相似。 Here's more information on using slotted App Services. 这是有关使用插槽式App Services的更多信息 。 It's intended to be used as a way to create staging and production environments. 它旨在用作创建暂存和生产环境的一种方式。
I'm not sure about having multiple sites as sub-directories. 我不确定要将多个站点作为子目录。
What you can do is setup 1 Standard App Service Plan and setup multiple App Services within that plan and use subdomains to point to those App Services (CustomerA.mysite.com, CustomerB.mysite.com). 您可以做的是设置1个标准App Service计划,并在该计划中设置多个App Services,然后使用子域指向这些App Services(CustomerA.mysite.com,CustomerB.mysite.com)。 There is no additional charge for setting up multiple App Services within a single App Service Plan. 在一个应用程序服务计划中设置多个应用程序服务无需额外付费。
This has a few advantages. 这有一些优点。 You can use Azure's Application Settings Management, you can use deployment slots, and you could update each customer's production environment 1 at a time allowing you to have 1 customer Beta testing while others are running stable code. 您可以使用Azure的应用程序设置管理,可以使用部署槽,并且可以一次更新每个客户的生产环境1,从而允许您进行1个客户Beta测试,而其他人则在运行稳定的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.