适用于ARM Azure Web应用程序的createUiDefinition.json

问题描述 投票:3回答:1

我为azure web app创建了ARM模板。我需要将ARM模板发布到azure市场。我使用azure发布门户网站https://publish.windowsazure.com/workspace/multi-resource-solutions发布了ARM模板。

要将ARM模板安装到azure market place,zip文件必须包含mainTemplate.json和createUiDefinition.json。我在https://github.com/Azure/azure-quickstart-templates中找到了一些createUiDefination.json文件的样本,但是所有的createUiDefination.json都是针对VM的。我无法为Azure Web应用程序找到createUiDefination.json的示例或教程。

我需要验证azure web app网站名称是否已存在。还需要创建或使用应用服务计划。

是否有任何教程或示例用于为azure Web应用程序创建createUiDefination.json?

json azure arm-template azure-marketplace
1个回答
0
投票

我需要验证azure web app网站名称是否已存在。

这是不可能的,您需要在站点名称中添加唯一的String,以确保站点名称是全局唯一的。例如,您可以在ARM模板中使用此函数:uniqueString()

Similar question was answered by a Microsoft employee.

还需要创建或使用应用服务计划。

将应用服务计划添加到Azure资源管理器模板。例如这样:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "hostingPlanName": {
      "type": "string",
      "minLength": 1
    },
    "skuName": {
      "type": "string",
      "defaultValue": "F1",
      "allowedValues": [
        "F1",
        "D1",
        "B1",
        "B2",
        "B3",
        "S1",
        "S2",
        "S3",
        "P1",
        "P2",
        "P3",
        "P4"
      ],
      "metadata": {
        "description": "Describes plan's pricing tier and capacity. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
      }
    },
    "skuCapacity": {
      "type": "int",
      "defaultValue": 1,
      "minValue": 1,
      "metadata": {
        "description": "Describes plan's instance count"
      }
    }
  },
  "variables": {
    "webSiteName": "[concat('webSite', uniqueString(resourceGroup().id))]"
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "[parameters('hostingPlanName')]",
      "type": "Microsoft.Web/serverfarms",
      "location": "[resourceGroup().location]",
      "tags": {
        "displayName": "HostingPlan"
      },
      "sku": {
        "name": "[parameters('skuName')]",
        "capacity": "[parameters('skuCapacity')]"
      },
      "properties": {
        "name": "[parameters('hostingPlanName')]"
      }
    },
    {
      "apiVersion": "2015-08-01",
      "name": "[variables('webSiteName')]",
      "type": "Microsoft.Web/sites",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
        "displayName": "Website"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
      ],
      "properties": {
        "name": "[variables('webSiteName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
      }
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.