2

我正在尝试使用 Azure 资源管理器自动化网站部署。网站创建和代码部署工作正常,但我无法将新网站附加到现有的虚拟主机计划。

我正在使用 2015-08-01 API,从不同的例子中我认为这个模板应该可以工作(它不......):

部署在“Microsoft.Web/sites/config”处失败,并且正在为该站点分配一个新的默认免费托管计划。

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "siteName": {
        "type": "string"
    },
    "subscriptionId": {
        "type": "string"
    },
    "setting1": {
        "type": "string"
    },
    "setting2": {
        "type": "string"
    }
},
"resources": [
    {
        "apiVersion": "2015-08-01",
        "type": "Microsoft.Web/sites",
        "name": "[parameters('siteName')]",
        "location": "[resourceGroup().location]",
        "properties": {
            "serverFarmId ": "/subscriptions/xxxxxx/resourceGroups/xxxxxx/providers/Microsoft.Web/serverfarms/xxxxxx"
        },
        "resources": [
            {
                "apiVersion": "2015-08-01",
                "name": "web",
                "type": "config",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
                ],
                "properties": {
                    "phpVersion": "off",
                    "netFrameworkVersion": "v4.6",
                    "use32BitWorkerProcess": false,
                    "webSocketsEnabled": true,
                    "alwaysOn": true,
                    "requestTracingEnabled": false,
                    "httpLoggingEnabled": false,
                    "logsDirectorySizeLimit": 40,
                    "detailedErrorLoggingEnabled": false,
                    "appSettings": [
                        {
                            "Name": "setting1",
                            "Value": "Value1"
                        },
                        {
                            "Name": "setting2",
                            "Value": "Value2"
                        }
                    ]
                }
            },
            {
                "apiVersion": "2015-08-01",
                "type": "extensions",
                "name": "MSDeploy",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/sites', parameters('siteName'))]"
                ],
                "properties": {
                    "packageUri": "xxxxxxxx",
                    "dbType": "None",
                    "connectionString": ""
                }
            }
        ]
    }
],
"outputs": {
    "siteUri": {
        "type": "string",
        "value": "[concat('http://',reference(resourceId('Microsoft.Web/sites', parameters('siteName'))).hostNames[0])]"
    }
}

}

4

1 回答 1

2

我最终退回到 2014-06-01 API,并对脚本进行了一些调整,能够做我想做的事。

提供脚本以供将来参考。

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "siteName": {
        "type": "string"
    },
    "subscriptionId": {
        "type": "string"
    },
    "hostingPlanName": {
        "type": "string"
    },
    "setting1": {
        "type": "string"
    },
    "setting2": {
        "type": "string"
    }
},
"resources": [
    {
        "apiVersion": "2014-06-01",
        "type": "Microsoft.Web/sites",
        "name": "[parameters('siteName')]",
        "location": "[resourceGroup().location]",
        "dependsOn": [

        ],
        "properties": {
            "name": "[parameters('siteName')]",
            "serverFarm": "[parameters('hostingPlanName')]"
        },
        "resources": [
            {
                "apiVersion": "2014-06-01",
                "name": "web",
                "type": "config",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
                    "[concat('Microsoft.Web/Sites/', parameters('siteName'), '/Extensions/MSDeploy')]"
                ],
                "properties": {
                    "phpVersion": "off",
                    "netFrameworkVersion": "v4.6",
                    "use32BitWorkerProcess": false,
                    "webSocketsEnabled": true,
                    "alwaysOn": true,
                    "requestTracingEnabled": false,
                    "httpLoggingEnabled": false,
                    "logsDirectorySizeLimit": 40,
                    "detailedErrorLoggingEnabled": false
                }
            },
            {
                "apiVersion": "2014-11-01",
                "name": "appsettings",
                "type": "config",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
                    "[concat('Microsoft.Web/Sites/', parameters('siteName'), '/Extensions/MSDeploy')]"

                ],
                "properties": {
                    "Setting1": "[parameters('setting1')]",
                    "Setting2": "[parameters('setting2')]"
                }
            },
            {
                "apiVersion": "2015-08-01",
                "type": "extensions",
                "name": "MSDeploy",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
                ],
                "properties": {
                    "packageUri": "https://xxxxx.zip",
                    "dbType": "None",
                    "connectionString": ""
                }
            }
        ]
    }
]

}

于 2015-10-02T11:21:25.377 回答