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

时间:2015-06-29 16:50:45

标签: azure azure-web-sites azure-resource-manager azure-app-service-envrmnt

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

我手动创建了ASE,因为它们需要3个多小时才能启动(旁注:为什么,微软,为什么用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'))]"
            }
        }
    ]
}

然后使用模板:

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

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

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

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

2 个答案:

答案 0 :(得分:3)

因此,毫不奇怪,完全缺乏Azure文档,浪费了我更多的时间。

问题在于ASE资源的apiVersion。你不能使用最新版本,看起来版本是资源特定的,但如果你正在创建一个 new 它也看起来只有 很重要>资源,因此您将获得不一致的结果,具体取决于操作。

同样令人担忧的是模板验证正常,但实际部署只是挂起。如果您遇到类似这样的挂起部署,请检查您的apiVersion:

PS C:\Templates> New-AzureResourceGroupDeployment -ResourceGroupName
"rg-ase-dev"  -TemplateFile .\ase_asp_only.json -Verbose
VERBOSE: 12:08:24 PM - Template is valid.
VERBOSE: 12:08:25 PM - Create template deployment 'ase_asp_only'.
VERBOSE: 12:08:27 PM - Resource Microsoft.Web/serverFarms
'rg-ase-dev-asp-wp1-2' provisioning status is running

(this hangs)

AFAICT,ARMExplorer似乎在资源的链接中提供了有效的apiVersion,因此我将坚持使用这些版本,直到Microsoft不可避免地打破它。

PITA是什么。

答案 1 :(得分:0)

我建议使用gallery template创建一个空的网络应用,通过网络应用创建应用服务计划。

  New-AzureResourceGroup -Name <groupname> -Location "<location>" -GalleryTemplateIdentity Microsoft.WebSite.0.3.17-preview

要保存模板,您可以

  Save-AzureResourceGroupGalleryTemplate -Identity Microsoft.WebSite.0.3.17-preview -Path <local path to save file>