Skip to content
Permalink
2a7749eb22
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
343 lines (343 sloc) 12.1 KB
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmSize": {
"type": "string",
"defaultValue": ""
},
"adminUsername": {
"type": "string",
"defaultValue": "takekazu.omi"
},
"adminPassword": {
"type": "secureString"
}
},
"functions": [],
"variables": {},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2019-10-01",
"name": "vnetMod",
"properties": {
"expressionEvaluationOptions": {
"scope": "inner"
},
"mode": "Incremental",
"parameters": {
"vnetName": {
"value": "vNet"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"type": "string",
"defaultValue": "vNet"
},
"addressPrefix": {
"type": "string",
"defaultValue": "10.1.0.0/16"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
}
},
"functions": [],
"variables": {
"subnet1": {
"name": "subnet1",
"properties": {
"addressPrefix": "10.1.1.0/24",
"serviceEndpoints": [
{
"service": "Microsoft.Storage",
"locations": [
"japaneast",
"japanwest"
]
}
]
}
},
"subnet2": {
"name": "subnet2",
"properties": {
"addressPrefix": "10.1.2.0/24"
}
}
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-05-01",
"name": "[parameters('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('addressPrefix')]"
]
},
"subnets": [
"[variables('subnet1')]",
"[variables('subnet2')]"
]
}
}
],
"outputs": {
"results": {
"type": "object",
"value": {
"vnet": "[reference(resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName')), '2020-05-01', 'full')]"
}
}
}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2019-10-01",
"name": "vmMod",
"properties": {
"expressionEvaluationOptions": {
"scope": "inner"
},
"mode": "Incremental",
"parameters": {
"vnet": {
"value": "[reference(resourceId('Microsoft.Resources/deployments', 'vnetMod'), '2019-10-01').outputs.results.value.vnet]"
},
"adminUsername": {
"value": "[parameters('adminUsername')]"
},
"adminPassword": {
"value": "[parameters('adminPassword')]"
},
"vmSize": {
"value": "[parameters('vmSize')]"
},
"vmName": {
"value": "vm1"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnet": {
"type": "object"
},
"vmName": {
"type": "string",
"defaultValue": "linux-vm"
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_B1s"
},
"adminUsername": {
"type": "string",
"defaultValue": "takekazu.omi"
},
"adminPassword": {
"type": "secureString"
},
"subnetName": {
"type": "string",
"defaultValue": "subnet1"
},
"customData": {
"type": "string",
"defaultValue": ""
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
}
},
"functions": [],
"variables": {
"nicName": "[format('{0}-nic1', parameters('vmName'))]",
"nsgName": "[format('{0}-nsg', parameters('vmName'))]",
"diskName": "[format('{0}-osdisk-1', parameters('vmName'))]",
"publicIPName": "[format('{0}-public-ip-1', parameters('vmName'))]",
"vnetName": "[last(split(parameters('vnet').resourceId, '/'))]",
"subnetId": "[resourceId(parameters('vnet').resourceGroupName, 'Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), parameters('subnetName'))]",
"storageAccountName": "[take(format('{0}diag{1}', replace(parameters('vmName'), '-', ''), uniqueString(resourceGroup().id)), 24)]",
"imageReference": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "18.04-LTS",
"version": "latest"
}
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"storageProfile": {
"imageReference": "[variables('imageReference')]",
"osDisk": {
"osType": "Linux",
"name": "[variables('diskName')]",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
},
"diskSizeGB": 30
},
"dataDisks": []
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"customData": "[if(equals(parameters('customData'), ''), null(), parameters('customData'))]",
"linuxConfiguration": {
"provisionVMAgent": true
},
"secrets": [],
"allowExtensionOperations": true
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2020-05-01",
"name": "[variables('nicName')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetId')]"
},
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]"
}
}
}
],
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]",
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]"
]
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-05-01",
"name": "[variables('publicIPName')]",
"location": "[parameters('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"publicIPAddressVersion": "IPv4",
"idleTimeoutInMinutes": 4
},
"sku": {
"name": "Basic"
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2020-05-01",
"name": "[variables('nsgName')]",
"location": "[parameters('location')]",
"properties": {
"securityRules": []
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"kind": "Storage",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [
{
"id": "[variables('subnetId')]",
"action": "Allow"
}
],
"defaultAction": "Deny"
},
"allowBlobPublicAccess": false,
"minimumTlsVersion": "TLS1_2"
}
}
],
"outputs": {
"results": {
"type": "object",
"value": {
"vm": "[reference(resourceId('Microsoft.Compute/virtualMachines', parameters('vmName')), '2020-06-01', 'full')]",
"nic": "[reference(resourceId('Microsoft.Network/networkInterfaces', variables('nicName')), '2020-05-01', 'full')]",
"nsg": "[reference(resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName')), '2020-05-01', 'full')]",
"publicIP": "[reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName')), '2020-05-01', 'full')]",
"diagstg": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01', 'full')]"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Resources/deployments', 'vnetMod')]"
]
}
],
"outputs": {
"results": {
"type": "object",
"value": {
"vnet": "[reference(resourceId('Microsoft.Resources/deployments', 'vnetMod'), '2019-10-01').outputs]",
"vm": "[reference(resourceId('Microsoft.Resources/deployments', 'vmMod'), '2019-10-01').outputs]"
}
}
}
}