text Ubuntu Azure ARM VM模板

Posted

tags:

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

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "dnsLabelPrefix": {
      "type": "string",
      "metadata": {
        "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
      }
    },
    "adminUsername": {
      "type": "string",
      "metadata": {
        "description": "User name for the Virtual Machine."
      }
    },
    "adminPassword": {
      "type": "string",
      "defaultValue": "securestring",
      "metadata": {
        "description": "Password for the Virtual Machine."
      }
    },
    "virtualNetworkName": {
      "type": "string",
      "defaultValue": "ExistingVnet",
      "metadata": {
        "description": "Password for the Virtual Machine."
      }
    },
    "subnetName": {
      "type": "string",
      "defaultValue": "ExistingSubnet",
      "metadata": {
        "description": "Password for the Virtual Machine."
      }
    },
    "customData": {
      "type": "string",
      "defaultValue": "echo customData",
      "metadata": {
        "description": "String passed down to the Virtual Machine."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
    "imagePublisher": "OpenLogic",
    "imageOffer": "CentOS",
    "nicName": "[concat(parameters('dnsLabelPrefix'), '-networkInterface-1')]",
    "vmName": "[parameters('dnsLabelPrefix')]",
    "publicIPAddressName": "[concat(parameters('dnsLabelPrefix'), '-publicIp')]",
    "publicIPAddressType": "Dynamic",
    "storageAccountType": "Standard_LRS",
    "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
    "subnet1Ref": "[concat(variables('vnetID'),'/subnets/',parameters('subnetName'))]",
    "apiVersion": "2015-06-15"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('storageAccountName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]",
      "properties": {
        "accountType": "[variables('storageAccountType')]"
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[variables('publicIPAddressName')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
        "dnsSettings": {
          "domainNameLabel": "[parameters('dnsLabelPrefix')]"
        }
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/networkInterfaces",
      "name": "[variables('nicName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
      ],
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
              },
              "subnet": {
                "id": "[variables('subnet1Ref')]"
              }
            }
          }
        ]
      }
    },
    {
      "apiVersion": "2016-04-30-preview",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[variables('vmName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
        "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_B1s"
        },
        "osProfile": {
          "computerName": "[variables('vmName')]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]",
          "customData": "[base64(parameters('customData'))]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "[variables('imagePublisher')]",
            "offer": "[variables('imageOffer')]",
            "sku": "7-CI",
            "version": "latest"
          },
          "osDisk": {
            "createOption": "FromImage"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": true,
            "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), variables('apiVersion')).primaryEndpoints.blob)]"
          }
        }
      }
    }
  ]
}
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "dnsLabelPrefix": {
      "type": "string",
      "metadata": {
        "description": "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
      }
    },
    "adminUsername": {
      "type": "string",
      "metadata": {
        "description": "User name for the Virtual Machine."
      }
    },
    "adminPassword": {
      "type": "string",
      "defaultValue": "securestring",
      "metadata": {
        "description": "Password for the Virtual Machine."
      }
    },
    "virtualNetworkName": {
      "type": "string",
      "defaultValue": "ExistingVnet",
      "metadata": {
        "description": "Password for the Virtual Machine."
      }
    },
    "subnetName": {
      "type": "string",
      "defaultValue": "ExistingSubnet",
      "metadata": {
        "description": "Password for the Virtual Machine."
      }
    },
    "customData": {
      "type": "string",
      "defaultValue": "echo customData",
      "metadata": {
        "description": "String passed down to the Virtual Machine."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    "storageAccountName": "[concat(replace(parameters('dnsLabelPrefix'),'-', ''), uniquestring(resourceGroup().id)]",
    "imagePublisher": "Canonical",
    "imageOffer": "UbuntuServer",
    "nicName": "[concat(parameters('dnsLabelPrefix'), '-networkInterface-1')]",
    "vmName": "[parameters('dnsLabelPrefix')]",
    "publicIPAddressName": "[concat(parameters('dnsLabelPrefix'), '-publicIp')]",
    "publicIPAddressType": "Dynamic",
    "storageAccountType": "Standard_LRS",
    "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
    "subnet1Ref": "[concat(variables('vnetID'),'/subnets/',parameters('subnetName'))]",
    "apiVersion": "2015-06-15"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('storageAccountName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]",
      "properties": {
        "accountType": "[variables('storageAccountType')]"
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[variables('publicIPAddressName')]",
      "location": "[parameters('location')]",
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
        "dnsSettings": {
          "domainNameLabel": "[parameters('dnsLabelPrefix')]"
        }
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/networkInterfaces",
      "name": "[variables('nicName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
      ],
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
              },
              "subnet": {
                "id": "[variables('subnet1Ref')]"
              }
            }
          }
        ]
      }
    },
    {
      "apiVersion": "2016-04-30-preview",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[variables('vmName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
        "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_B1s"
        },
        "osProfile": {
          "computerName": "[variables('vmName')]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]",
          "customData": "[base64(parameters('customData'))]"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "[variables('imagePublisher')]",
            "offer": "[variables('imageOffer')]",
            "sku": "18.04-LTS",
            "version": "latest"
          },
          "osDisk": {
            "createOption": "FromImage"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": true,
            "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), variables('apiVersion')).primaryEndpoints.blob)]"
          }
        }
      }
    }
  ]
}
  "resources": [
    {
       "apiVersion": "2017-05-10",
       "name": "linkedTemplate",
       "type": "Microsoft.Resources/deployments",
       "dependsOn": [
         "[concat('Microsoft.Network/virtualNetworks/', variables('uniqueVnetCoreName'))]"
       ],
       "properties": {
         "mode": "Incremental",
         "templateLink": {
            "uri":"https://gist.github.com/xenefix/406dcd2f8da4afc13918030e79166f7f/raw/e23acabaf3c570fd47f0f32bd68bc46153bb95dd/vm_template.json",
            "contentVersion":"1.0.0.0"
         },
         "parameters": {
            "dnsLabelPrefix":{"value": "swamble"},
            "adminUsername": {"value": "swamble"},
            "adminPassword": {"value": "swambleswamble!1"},
            "virtualNetworkName": {"value": "VNet-Core"},
            "subnetName": {"value": "VNet-Core-Subnet-1"},
            "customData": {"value": "echo customData"},
            "location": {"value": "[resourceGroup().location]"}
          }
       }
    }
  ]

以上是关于text Ubuntu Azure ARM VM模板的主要内容,如果未能解决你的问题,请参考以下文章

Azure ARM (14) 设置ARM VM的Availability Set

Azure ARM-DSC VM配置

Azure VM从ASM迁移到ARM

Azure VM从ASM迁移到ARM

Azure ARM 模板,VM扩展命令

Azure ARM - DSC VM 配置