我正在尝试在 Azure 上部署 ubuntu 模板。我已经从一台未安装任何内容的现有机器创建了模板。以下是配置:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachines_StagingPortalWebServerNE_adminPassword": {
"defaultValue": null,
"type": "SecureString"
},
"virtualMachines_StagingPortalWebServerNE_name": {
"defaultValue": "StagingPortalWebServerNE",
"type": "String"
},
"networkInterfaces_stagingportalwebserv634_name": {
"defaultValue": "stagingportalwebserv634",
"type": "String"
},
"networkSecurityGroups_StagingPortalWebServerNE_name": {
"defaultValue": "StagingPortalWebServerNE",
"type": "String"
},
"publicIPAddresses_StagingPortalWebServerNE_name": {
"defaultValue": "StagingPortalWebServerNE",
"type": "String"
},
"virtualNetworks_StagingPortalWebServerNEResourceGroup_name": {
"defaultValue": "StagingPortalWebServerNEResourceGroup",
"type": "String"
},
"storageAccounts_stagingportalwebserv2173_name": {
"defaultValue": "stagingportalwebserv2173",
"type": "String"
}
},
"variables": {},
"resources": [
{
"comments": "Generalized from resource: '/subscriptions/d897fa29-7454-411b-9709-d11a645bf42f/resourceGroups/StagingPortalWebServerNEResourceGroup/providers/Microsoft.Compute/virtualMachines/StagingPortalWebServerNE'.",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('virtualMachines_StagingPortalWebServerNE_name')]",
"apiVersion": "2015-06-15",
"location": "northeurope",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A1"
},
"storageProfile": {
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "14.04.4-LTS",
"version": "latest"
},
"osDisk": {
"name": "[parameters('virtualMachines_StagingPortalWebServerNE_name')]",
"createOption": "FromImage",
"vhd": {
"uri": "[concat('https', '://', parameters('storageAccounts_stagingportalwebserv2173_name'), '.blob.core.windows.net', concat('/vhds/', parameters('virtualMachines_StagingPortalWebServerNE_name'),'201653123853.vhd'))]"
},
"caching": "ReadWrite"
},
"dataDisks": []
},
"osProfile": {
"computerName": "[parameters('virtualMachines_StagingPortalWebServerNE_name')]",
"adminUsername": "spotscale",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "/path/to/key",
"keyData": "ssh-rsa sshkey"
}
]
}
},
"secrets": [],
"adminPassword": "[parameters('virtualMachines_StagingPortalWebServerNE_adminPassword')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_stagingportalwebserv634_name'))]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_stagingportalwebserv2173_name'))]",
"[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_stagingportalwebserv634_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/d897fa29-7454-411b-9709-d11a645bf42f/resourceGroups/StagingPortalWebServerNEResourceGroup/providers/Microsoft.Network/networkInterfaces/stagingportalwebserv634'.",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('networkInterfaces_stagingportalwebserv634_name')]",
"apiVersion": "2015-06-15",
"location": "northeurope",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAddress": "10.5.0.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_StagingPortalWebServerNE_name'))]"
},
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_StagingPortalWebServerNEResourceGroup_name')), '/subnets/default')]"
}
}
}
],
"dnsSettings": {
"dnsServers": []
},
"enableIPForwarding": false,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_StagingPortalWebServerNE_name'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_StagingPortalWebServerNE_name'))]",
"[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_StagingPortalWebServerNEResourceGroup_name'))]",
"[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_StagingPortalWebServerNE_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/d897fa29-7454-411b-9709-d11a645bf42f/resourceGroups/StagingPortalWebServerNEResourceGroup/providers/Microsoft.Network/networkSecurityGroups/StagingPortalWebServerNE'.",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[parameters('networkSecurityGroups_StagingPortalWebServerNE_name')]",
"apiVersion": "2015-06-15",
"location": "northeurope",
"properties": {
"securityRules": [
{
"name": "default-allow-ssh",
"properties": {
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1000,
"direction": "Inbound"
}
},
{
"name": "allow-internet",
"properties": {
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "80",
"sourceAddressPrefix": "Internet",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1010,
"direction": "Inbound"
}
}
]
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/d897fa29-7454-411b-9709-d11a645bf42f/resourceGroups/StagingPortalWebServerNEResourceGroup/providers/Microsoft.Network/publicIPAddresses/StagingPortalWebServerNE'.",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddresses_StagingPortalWebServerNE_name')]",
"apiVersion": "2015-06-15",
"location": "northeurope",
"properties": {
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/d897fa29-7454-411b-9709-d11a645bf42f/resourceGroups/StagingPortalWebServerNEResourceGroup/providers/Microsoft.Network/virtualNetworks/StagingPortalWebServerNEResourceGroup'.",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworks_StagingPortalWebServerNEResourceGroup_name')]",
"apiVersion": "2015-06-15",
"location": "northeurope",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.5.0.0/16"
]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.5.0.0/24"
}
}
]
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/d897fa29-7454-411b-9709-d11a645bf42f/resourceGroups/stagingportalwebserverneresourcegroup/providers/Microsoft.Storage/storageAccounts/stagingportalwebserv2173'.",
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('storageAccounts_stagingportalwebserv2173_name')]",
"apiVersion": "2015-06-15",
"location": "northeurope",
"tags": {},
"properties": {
"accountType": "Standard_LRS"
},
"dependsOn": []
}
]
}
当我部署模板时出现以下错误:
{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "TargetDiskBlobAlreadyExists",
"message": "Blob https://stagingportalwebserv2173.blob.core.windows.net/vhds/StagingPortalWebServerNE201653123853.vhd already exists. Please provide a different blob URI as target for disk 'StagingPortalWebServerNE'."
}
]
}
}
我知道对两个虚拟机使用同一个磁盘是个坏主意,但我不明白如何为这台机器创建一个新磁盘。任何帮助都非常感谢。