Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Met Azure DevTest Labs kunt u eenvoudig VM's maken in een lab met ingebouwde netwerken. Het heeft veel flexibiliteit met de mogelijkheid om omgevingen met meerdere VM's te maken. In dit artikel leest u hoe u VM's in een omgeving verbindt met het virtuele labnetwerk. Een scenario waarin u deze functie gebruikt, is het instellen van een N-laag-app met een SQL Server-gegevenslaag die is verbonden met het lab-VNet, zodat test-VM's in het lab toegang hebben tot deze.
Voorbeeldomgeving die gebruikmaakt van lab-VNet
Hier volgt een eenvoudige omgevingssjabloon waarmee het subnet van het lab wordt verbonden. In dit voorbeeld vertegenwoordigt de DTLSubnetId parameter de id van het subnet waarin het lab bestaat. Dit wordt toegewezen aan: $(LabSubnetId), die automatisch door DevTest Labs wordt omgezet in de ID van het subnet van het lab. De subneteigenschap van de netwerkinterface van de VIRTUELE machine in deze definitie is zo ingesteld DTLSubnetId dat deze verbinding maakt met hetzelfde subnet.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"DTLEnvironVmStoretype": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS",
"Standard_RAGRS",
"Premium_LRS"
]
},
"DTLEnvironVmName": {
"type": "string",
"minLength": 1
},
"VmAdminUserName": {
"type": "string",
"minLength": 1
},
"VmAdminUserPassword": {
"type": "securestring"
},
"DTLEnvironVmOsVersion": {
"type": "string",
"defaultValue": "2012-R2-Datacenter",
"allowedValues": [
"2008-R2-SP1",
"2012-Datacenter",
"2012-R2-Datacenter",
"Windows-Server-Technical-Preview"
]
},
"DTLSubnetId": {
"type": "string",
"defaultValue": "$(LabSubnetId)"
}
},
"variables": {
"DTLEnvironStoreName": "[toLower([concat(parameters('DTLEnvironVmName'), 'storename')])]",
"DTLEnvironVmImagePublisher": "MicrosoftWindowsServer",
"DTLEnvironVmImageOffer": "WindowsServer",
"DTLEnvironVmOSDiskName": "[concat(parameters('DTLEnvironVmName'), 'OSDisk')]",
"DTLEnvironVmSize": "Standard_D2_v2",
"DTLEnvironVmStorageAccountContainerName": "vhds",
"DTLEnvironVmNicName": "[concat(parameters('DTLEnvironVmName'), 'NetworkInterface')]"
},
"resources": [{
"name": "[variables('DTLEnvironStoreName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "2016-01-01",
"sku": {
"name": "[parameters('DTLEnvironVmStoretype')]"
},
"dependsOn": [],
"tags": {
"displayName": "[variables('DTLEnvironStoreName')]"
},
"kind": "Storage"
},
{
"name": "[variables('DTLEnvironVmNicName')]",
"type": "Microsoft.Network/networkInterfaces",
"location": "southeastasia",
"apiVersion": "2016-03-30",
"dependsOn": [],
"tags": {
"displayName": "[variables('DTLEnvironVmNicName')]"
},
"properties": {
"ipConfigurations": [{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[parameters('DTLSubnetId')]"
}
}
}]
}
},
{
"name": "[parameters('DTLEnvironVmName')]",
"type": "Microsoft.Compute/virtualMachines",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('DTLEnvironStoreName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', variables('DTLEnvironVmNicName'))]"
],
"tags": {
"displayName": "[parameters('DTLEnvironVmName')]"
},
"properties": {
"hardwareProfile": {
"vmSize": "[variables('DTLEnvironVmSize')]"
},
"osProfile": {
"computerName": "[parameters('DTLEnvironVmName')]",
"adminUsername": "[parameters('VmAdminUserName')]",
"adminPassword": "[parameters('VmAdminUserPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('DTLEnvironVmImagePublisher')]",
"offer": "[variables('DTLEnvironVmImageOffer')]",
"sku": "[parameters('DTLEnvironVmOsVersion')]",
"version": "latest"
},
"osDisk": {
"name": "[variables('DTLEnvironVmOSDiskName')]",
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('DTLEnvironStoreName')), '2016-01-01').primaryEndpoints.blob, variables('DTLEnvironVmStorageAccountContainerName'), '/', variables('DTLEnvironVmOSDiskName'), '.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('DTLEnvironVmNicName'))]"
}]
}
}
}
],
"outputs": {}
}
Volgende stappen
Zie het volgende artikel voor het gebruik van Azure Portal om deze bewerkingen uit te voeren: Een VIRTUELE machine opnieuw opstarten.