json ARM模板与copyindex #arm #azure

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json ARM模板与copyindex #arm #azure相关的知识,希望对你有一定的参考价值。

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "Hostheader": {
      "type": "string",
      "defaultValue": "servicebus.customername.org",
      "metadata": {
        "description": "Add the hostheader for the BizTalk Webservice"
      }
    },
    "NumberOfBizTalkServers": {
      "type": "int",
      "defaultValue": 1,
      "metadata": {
        "description": "Add the number of BizTalk servers"
      }
    },
    "BtsVmSize": {
      "type": "string",
      "defaultValue": "Standard_F2s",
      "allowedValues": [
        "Standard_F2s",
        "Standard_F4s"
      ]
    },
    "StorageType": {
        "type": "string",
        "defaultValue": "Premium_LRS"
      },
      "BootDiagnosticsStorageType": {
        "type": "string",
        "defaultValue": "Standard_LRS"
      },
      "StorageName": {
        "type": "string",
        "defaultValue": "btsteststorage",
        "metadata": {
          "description": "Should be unique, lowercase and max 24 chars"
        }
      },
      "virtualNetworkSubnet": {
        "type": "string",
        "defaultValue": "TestBackendSubnet"
      },
      "virtualNetworkName": {
        "type": "string",
        "defaultValue": "rit-01-vn"
      },
      "virtualNetworkResourceGroup": {
        "type": "string",
        "defaultValue": "core-networking-rg"
      },
      "FQDN": {
        "type": "string",
        "minLength": 1,
        "metadata": {
          "description": "This the FQDN from the domain that will be joined"
        }
      },
      "BtsNode1Name": {
        "type": "string",
        "minLength": 1
      },
      "SqlName": {
        "type": "string",
        "minLength": 1
      },
    "BtsNode1Ip": {
      "type": "string",
      "minLength": 1,
      "metadata": {
        "description": "IP adress WITHOUT the last digit. E.g. 192.168.0.25 (if you want the IP to be 192.168.0.251)"
      }
    },
      "SqlIp": {
        "type": "string",
        "minLength": 1
      },
      "AdminUserName": {
        "type": "string",
        "minLength": 1
      },
      "AdminPassword": {
        "type": "securestring"
      },
      "WindowsOSVersion": {
        "type": "string",
        "defaultValue": "2016-Datacenter"
      },
      "DomainAdminUserName": {
        "type": "string",
        "minLength": 1,
        "metadata": {
          "description": "username of the domain admin that can join the server to the domain"
        }
      },
      "DomainPassword": {
        "type": "securestring",
        "metadata": {
          "description": "password of the domain admin that can join the server to the domain"
        }
      },
      "_artifactsLocation": {
        "type": "string",
        "metadata": {
          "description": "Auto-generated container in staging storage account to receive post-build staging folder upload"
        }
      },
      "_artifactsLocationSasToken": {
        "type": "securestring",
        "metadata": {
          "description": "Auto-generated token to access _artifactsLocation"
        }
      }
    },
  "variables": {
    "Backslash": "\\",
    "storageName": "[parameters('StorageName')]",
    "diagnosticsStorageName": "[concat('diag', uniqueString(resourceGroup().id))]",
    "ImagePublisher": "MicrosoftWindowsServer",
    "ImageOffer": "WindowsServer",
    "BtsNode1OSDiskName": "[concat(parameters('BtsNode1Name'),'-OSDisk')]",
    "SqlOSDiskName": "SqlOSDisk",
    "BtsVmSize": "Standard_F2s",
    "SqlVmSize": "Standard_DS2_v2",
    "VnetID": "[resourceId(parameters('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
    "SubnetRef": "[concat(variables('VnetID'), '/subnets/', parameters('virtualNetworkSubnet'))]",
    "StorageAccountContainerName": "vhds",
    "BtsNode1NicName": "[concat(parameters('BtsNode1Name'),'-nic')]",
    "SqlNicName": "[concat(parameters('SqlName'), '-nic')]",
    "BizTalkConfigurationArchiveFolder": "DSC",
    "BizTalkConfigurationArchiveFileName": "BizTalkConfiguration.zip",
    "SqlConfigurationArchiveFolder": "DSC",
    "SqlConfigurationArchiveFileName": "SqlConfiguration.zip",
    "PrepareServerScriptFolder": "CustomScripts",
    "PrepareServerScriptFileName": "PrepareServer.ps1"
  },
  "resources": [
    {
      "name": "[variables('storageName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "location": "[resourceGroup().location]",
      "apiVersion": "2016-01-01",
      "sku": {
        "name": "[parameters('storageType')]"
      },
      "dependsOn": [],
      "tags": {
        "displayName": "StorageName"
      },
      "kind": "Storage"
    },
    {
      "name": "[variables('diagnosticsstorageName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "location": "[resourceGroup().location]",
      "apiVersion": "2016-01-01",
      "sku": {
        "name": "[parameters('BootDiagnosticsstorageType')]"
      },
      "dependsOn": [],
      "tags": {
        "displayName": "DiagnosticsStorageName"
      },
      "kind": "Storage"
    },
    {
      "name": "[concat(variables('BtsNode1NicName'),copyIndex(1))]",
      "type": "Microsoft.Network/networkInterfaces",
      "location": "westeurope",
      "apiVersion": "2016-03-30",
      "dependsOn": [],
      "tags": {
        "displayName": "[concat(variables('BtsNode1NicName'),copyIndex(1))]"
      },
      "copy": {
        "name": "BizTalkServerNicCopy",
        "count": "[parameters('NumberOfBizTalkServers')]"
      },
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Static",
              "privateIPAddress": "[concat(parameters('BtsNode1Ip'),copyIndex(1))]",
              "subnet": {
                "id": "[variables('SubnetRef')]"
              }
            }
          }
        ]
      }
    },
    {
      "name": "[variables('SqlNicName')]",
      "type": "Microsoft.Network/networkInterfaces",
      "location": "westeurope",
      "apiVersion": "2016-03-30",
      "dependsOn": [],
      "tags": {
        "displayName": "SqlNic"
      },
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Static",
              "privateIPAddress": "[parameters('SqlIp')]",
              "subnet": {
                "id": "[variables('SubnetRef')]"
              }
            }
          }
        ]
      }
    },
    {
      "name": "[parameters('SqlName')]",
      "type": "Microsoft.Compute/virtualMachines",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-06-15",
      "tags": {
        "displayName": "SqlServer"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]",
        "[resourceId('Microsoft.Network/networkInterfaces', variables('SqlNicName'))]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "[variables('SqlVmSize')]"
        },
        "osProfile": {
          "computerName": "[parameters('SqlName')]",
          "adminUsername": "[parameters('AdminUsername')]",
          "adminPassword": "[parameters('AdminPassword')]"
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('SqlNicName'))]"
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": "true",
            "storageUri": "[concat('https://',variables('diagnosticsStorageName'),'.blob.core.windows.net/')]"
          }
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "[variables('ImagePublisher')]",
            "offer": "[variables('ImageOffer')]",
            "sku": "[parameters('WindowsOSVersion')]",
            "version": "latest"
          },
          "osDisk": {
            "name": "SqlOSDisk",
            "vhd": {
              "uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2016-01-01').primaryEndpoints.blob, variables('StorageAccountContainerName'), '/', variables('SqlOSDiskName'), '.vhd')]"
            },
            "caching": "ReadWrite",
            "createOption": "FromImage"
          },

          "dataDisks": [
            {
              "vhd": {
                "uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageName'))).primaryEndpoints.blob,'vhds/', 'USERDB.vhd')]"
              },
              "name": "[concat(parameters('SqlName'),'-userdb')]",
              "caching": "ReadOnly",
              "diskSizeGB": "128",
              "lun": 0,
              "createOption": "Empty"
            },
            {
              "vhd": {
                "uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageName'))).primaryEndpoints.blob,'vhds/', 'USERLOG.vhd')]"
              },
              "name": "[concat(parameters('SqlName'),'-userlog')]",
              "caching": "None",
              "diskSizeGB": "128",
              "lun": 1,
              "createOption": "Empty"
            },
            {
              "vhd": {
                "uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageName'))).primaryEndpoints.blob,'vhds/', 'TEMPDB.vhd')]"
              },
              "name": "[concat(parameters('SqlName'),'-tempdb')]",
              "caching": "ReadOnly",
              "diskSizeGB": "64",
              "lun": 2,
              "createOption": "Empty"

            }
          ]
        }
      },
      "resources": [
        {
          "name": "PrepareServer",
          "type": "extensions",
          "location": "[resourceGroup().location]",
          "apiVersion": "2016-03-30",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', parameters('SqlName'))]"
          ],
          "tags": {
            "displayName": "PrepareServer"
          },
          "properties": {
            "publisher": "Microsoft.Compute",
            "type": "CustomScriptExtension",
            "typeHandlerVersion": "1.4",
            "autoUpgradeMinorVersion": true,
            "settings": {
              "fileUris": [
                "[concat(parameters('_artifactsLocation'), '/', variables('PrepareServerScriptFolder'), '/', variables('PrepareServerScriptFileName'), parameters('_artifactsLocationSasToken'))]"
              ],
              "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', variables('PrepareServerScriptFolder'), '/', variables('PrepareServerScriptFileName'))]"
            }
          }
        },
        {
          "apiVersion": "2015-06-15",
          "type": "extensions",
          "name": "SqlDomainJoin",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', parameters('SqlName'))]"
          ],
          "properties": {
            "publisher": "Microsoft.Compute",
            "type": "JsonADDomainExtension",
            "typeHandlerVersion": "1.3",
            "autoUpgradeMinorVersion": true,
            "settings": {
              "Name": "[parameters('FQDN')]",
              "Options": "3",
              "Restart": "true",
              "User": "[concat(parameters('FQDN'),variables('Backslash'),parameters('DomainAdminUserName'))]"
            },
            "protectedSettings": {
              "Password": "[parameters('DomainPassword')]"
            }
          }
        },
        {
          "name": "Microsoft.Powershell.DSC",
          "type": "extensions",
          "location": "[resourceGroup().location]",
          "apiVersion": "2016-03-30",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', parameters('SqlName'))]"
          ],
          "tags": {
            "displayName": "SqlConfiguration"
          },
          "properties": {
            "publisher": "Microsoft.Powershell",
            "type": "DSC",
            "typeHandlerVersion": "2.9",
            "autoUpgradeMinorVersion": true,
            "settings": {
              "configuration": {
                "url": "[concat(parameters('_artifactsLocation'), '/', variables('SqlConfigurationArchiveFolder'), '/', variables('SqlConfigurationArchiveFileName'))]",
                "script": "SqlConfiguration.ps1",
                "function": "Main"
              }
            },
            "protectedSettings": {
              "configurationUrlSasToken": "[parameters('_artifactsLocationSasToken')]"
            }
          }
        }
      ]
    },
    {
      "name": "[concat(parameters('BtsNode1Name'),copyIndex(1))]",
      "copy": {
        "name": "BizTalkServerCopy",
        "count": "[parameters('NumberOfBizTalkServers')]"
      },
      "type": "Microsoft.Compute/virtualMachines",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-06-15",
      "dependsOn": [
        "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]",
        "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('BtsNode1NicName'), copyIndex(1)))]"
      ],
      "tags": {
        "displayName": "[concat(parameters('BtsNode1Name'),copyIndex(1))]"
      },
      "properties": {
        "hardwareProfile": {
          "VmSize": "[variables('BtsVmSize')]"
        },
        "osProfile": {
          "computerName": "[parameters('BtsNode1Name')]",
          "adminUsername": "[parameters('AdminUsername')]",
          "adminPassword": "[parameters('AdminPassword')]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "[variables('ImagePublisher')]",
            "offer": "[variables('ImageOffer')]",
            "sku": "[parameters('WindowsOSVersion')]",
            "version": "latest"
          },
          "osDisk": {
            "name": "[variables('BtsNode1OsDiskName')]",
            "vhd": {
              "uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2016-01-01').primaryEndpoints.blob, variables('StorageName'), '/', concat(variables('BtsNode1OSDiskName'),copyIndex(1)), '.vhd')]",
            },
            "caching": "ReadWrite",
            "createOption": "FromImage"
          },
          "dataDisks": []
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('BtsNode1NicName'), copyIndex(1)))]"
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": "true",
            "storageUri": "[concat('https://',variables('diagnosticsStorageName'),'.blob.core.windows.net/')]"
          }
        }
      },
      "resources": [
        {
          "name": "PrepareServer",
          "type": "extensions",
          "location": "[resourceGroup().location]",
          "apiVersion": "2016-03-30",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', concat(parameters('BtsNode1Name'),copyIndex(1)))]"
          ],
          "tags": {
            "displayName": "PrepareServer"
          },
          "properties": {
            "publisher": "Microsoft.Compute",
            "type": "CustomScriptExtension",
            "typeHandlerVersion": "1.4",
            "autoUpgradeMinorVersion": true,
            "settings": {
              "fileUris": [
                "[concat(parameters('_artifactsLocation'), '/', variables('PrepareServerScriptFolder'), '/', variables('PrepareServerScriptFileName'), parameters('_artifactsLocationSasToken'))]"
              ],
              "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', variables('PrepareServerScriptFolder'), '/', variables('PrepareServerScriptFileName'))]"
            }
          }
        },
        {
          "apiVersion": "2015-06-15",
          "type": "extensions",
          "name": "BizTalkServerDomainJoin",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', concat(parameters('BtsNode1Name'),copyIndex(1)))]"
          ],
          "properties": {
            "publisher": "Microsoft.Compute",
            "type": "JsonADDomainExtension",
            "typeHandlerVersion": "1.3",
            "autoUpgradeMinorVersion": true,
            "settings": {
              "Name": "[parameters('FQDN')]",
              "Options": "3",
              "Restart": "true",
              "User": "[concat(parameters('FQDN'),variables('Backslash'),parameters('DomainAdminUserName'))]"
            },
            "protectedSettings": {
              "Password": "[parameters('DomainPassword')]"
            }
          }
        },
        {
          "name": "Microsoft.Powershell.DSC",
          "type": "extensions",
          "location": "[resourceGroup().location]",
          "apiVersion": "2016-03-30",
          "dependsOn": [
            "[resourceId('Microsoft.Compute/virtualMachines', concat(parameters('BtsNode1Name'),copyIndex(1)))]"
          ],
          "tags": {
            "displayName": "BizTalkConfiguration"
          },
          "properties": {
            "publisher": "Microsoft.Powershell",
            "type": "DSC",
            "typeHandlerVersion": "2.9",
            "autoUpgradeMinorVersion": true,
            "settings": {
              "configuration": {
                "url": "[concat(parameters('_artifactsLocation'), '/', variables('BizTalkConfigurationArchiveFolder'), '/', variables('BizTalkConfigurationArchiveFileName'))]",
                "script": "BizTalkConfiguration.ps1",
                "function": "Main"
              },
              "configurationArguments": {
                "Hostheader": "[parameters('Hostheader')]"
              }
            },
            "protectedSettings": {
              "configurationUrlSasToken": "[parameters('_artifactsLocationSasToken')]"
            }
          }
        }
      ]
    }
  ],
  "outputs": {}
}

以上是关于json ARM模板与copyindex #arm #azure的主要内容,如果未能解决你的问题,请参考以下文章

Azure ARM 模板,VM扩展命令

在为 ARM 模板部署创建的 Azure DevOps Pipeline 中找不到 JSON 文件路径

json Skatteberegning Eventhub ARM模板

json 功能App带有MSDeploy的ARM模板

发布后如何将 Azure 数据工厂参数放入 ARM 模板参数文件 (ARMTemplateParametersForFactory.json)

如何将对象参数作为哈希表传递给 json arm 模板?