简体   繁体   English

以编程方式部署Azure Web App

[英]Programmatically Deploy Azure Web App

Is there a way / API to Programmatically deploy Azure App services in particularly Web Apps to Azure ? 是否有一种方法/ API以编程方式将Azure App服务特别是Web应用程序部署到Azure?

or creating multiple instances of the site with different domain names ? 或使用不同的域名创建多个网站实例?

The basic idea is to sell a user configurable / themeable web site to the public as a product and automate the azure deployment after a client purchases the application ? 基本的想法是将用户可配置/可主题化的网站作为产品出售给公众,并在客户购买应用程序后自动进行azure部署?

You should have a lookt at Azure Resource Manager templates : 您应该了解Azure Resource Manager模板

Azure applications typically require a combination of resources (such as a database server, database, or website) to meet the desired goals. Azure应用程序通常需要资源组合(例如数据库服务器,数据库或网站)才能满足所需目标。 Rather than deploying and managing each resource separately, you can create an Azure Resource Manager template that deploys and provisions all of the resources for your application in a single, coordinated operation . 您可以创建Azure资源管理器模板,而不是单独部署和管理每个资源,该模板可在单个协调操作中为您的应用程序部署和配置所有资源 In the template, you define the resources that are needed for the application and specify deployment parameters to input values for different environments. 在模板中,您可以定义应用程序所需的资源,并指定部署参数以输入不同环境的值。 The template consists of JSON and expressions which you can use to construct values for your deployment. 该模板由JSON和表达式组成,您可以使用这些表达式为部署构造值。 This topic describes the sections of the template. 本主题描述模板的各个部分。

You can find good sample to start from the official website: 您可以从官方网站上找到好样品:

A lot. 很多。

A discussion of possible approaches at Deploy your app to Azure App Service . 讨论将应用程序部署到Azure App Service的可能方法。 You'll need to provide more details, or try something out and come back with more specific questions. 您需要提供更多详细信息,或者尝试一些内容并提出更具体的问题。 Alos read How to manage DNS records using PowerShell . Alos阅读如何使用PowerShell管理DNS记录

Apart from already suggested, maybe take a look at the xplat cli you can do everything you need for your scenario if you have your code in git somewhere: 除了已经建议的,如果你的代码在git某处,你可以看看xplat cli,你可以为你的场景做你需要的一切:

//Create the site
azure site create ...
//Add a custom domain
azure site domain add ...
//Deploy the site from your github repo
azure site deployment github ..
//Add sitespecific settings
azure site appsetting add ..

If you need database the xplat cli can create your databases too however it doesnt currently support to create a copy of an existing database for that so for that you have to turn to the Powershell solution mentioned in another answer. 如果您需要数据库,xplat cli也可以创建您的数据库,但它目前不支持为此创建现有数据库的副本,因此您必须转向另一个答案中提到的Powershell解决方案。

You can use the PowerShell command to clone your preconfigured web app - available starting v1.1.0 您可以使用PowerShell命令克隆预配置的Web应用程序 - 从v1.1.0开始提供

Get the object for source web app 获取源Web应用程序的对象

$srcapp = Get-AzureRmWebApp -ResourceGroupName SourceAzureResourceGroup -Name source-webapp

Create a new web app using the source web app 使用源Web应用程序创建新的Web应用程序

$destapp = New-AzureRmWebApp -ResourceGroupName DestinationAzureResourceGroup -Name dest-webapp -Location NewLocation -AppServicePlan DestinationAppServicePlan -SourceWebApp $srcapp

For more details check the following article: https://azure.microsoft.com/en-us/documentation/articles/app-service-web-app-cloning/ 有关更多详细信息,请查看以下文章: https//azure.microsoft.com/en-us/documentation/articles/app-service-web-app-cloning/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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