使用Azure Powershell在应用服务环境中创建Azure应用服务计划

thu*_* go 5 azure azure-web-sites azure-resource-manager azure-app-service-envrmnt

我正在尝试使用Azure应用服务环境(ASE),并且我在使用Powershell在ASE中创建应用服务计划(ASP)时遇到了困难.我试图使用New-AzureResourceNew-AzureResourceGroupDeploymentcmdlet 这样做,并且都以无益的方式失败.我需要能够以编程方式为我们的CI配置和部署过程创建这些(使用TeamCity).

我手动创建了ASE,因为它们需要3个多小时才能启动(旁注:为什么,Microsoft,为什么用ASE做任何事情要花费3个多小时?),并将工作池1定义为双节点P1池.

然后通过明智地使用http://resources.azure.com工具,我能够提取定义ASP的属性.

然后我为新ASP创建了一个简单的模板:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
"resources": [

        {
            "apiVersion": "2015-06-01",
            "name": "rg-ase-dev-asp-wp1-2",
            "type": "Microsoft.Web/serverfarms",
            "location": "East US",
            "properties": {
                "name": "rg-ase-dev-asp-wp1-2",
                "sku": "Premium",
                "workerSize": 0,
                "numberOfWorkers": "1",
                "hostingEnvironmentId": "[resourceId('Microsoft.Web/hostingEnvironments',parameters('rg-ase-dev'))]"
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

然后使用模板:

reResourceGroup1\Templates> New-AzureResourceGroupDeployment -ResourceGroupName
"rg-ase-dev" -TemplateFile .\ase_asp_only.json -Verbose
VERBOSE: 12:37:28 PM - Template is valid.
VERBOSE: 12:37:29 PM - Create template deployment 'ase_asp_only'.
VERBOSE: 12:37:36 PM - Resource Microsoft.Web/serverfarms
'rg-ase-dev-asp-wp1-2' provisioning status is running
Run Code Online (Sandbox Code Playgroud)

此命令将连续失败(即它将在​​预览门户中生成部署失败通知)几个小时,直到我想,它会被Azure后端杀死.

我已经尝试了模板的ASP属性值的大多数组合,但没有工作.我也尝试在同一个模板中创建一个ASP和一个依赖的WebApp,认为既然ASP只有在他们绑定了webapp的情况下才能存在,那就是我的问题.那太失败了.

有没有人得到模板化的ASP部署工作?或者这甚至是支持的操作?

小智 0

我建议使用库模板创建一个空的 Web 应用程序,该应用程序使用 Web 应用程序创建应用程序服务计划。

  New-AzureResourceGroup -Name <groupname> -Location "<location>" -GalleryTemplateIdentity Microsoft.WebSite.0.3.17-preview
Run Code Online (Sandbox Code Playgroud)

要保存模板,您可以

  Save-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSite.0.3.17-preview -Path <local path to save file>
Run Code Online (Sandbox Code Playgroud)