Skip to content

Instantly share code, notes, and snippets.

@MauricioZa
Last active February 26, 2024 05:07
Show Gist options
  • Select an option

  • Save MauricioZa/780f051af3ef297f0a54e452a5a1fbfd to your computer and use it in GitHub Desktop.

Select an option

Save MauricioZa/780f051af3ef297f0a54e452a5a1fbfd to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.16.2.56959",
"templateHash": "14427937023370378081"
}
},
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
"adminPassword": {
"type": "securestring",
"minLength": 12,
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"OSVersion": {
"type": "string",
"defaultValue": "2022-datacenter-azure-edition",
"allowedValues": [
"2016-datacenter-gensecond",
"2016-datacenter-server-core-g2",
"2016-datacenter-server-core-smalldisk-g2",
"2016-datacenter-smalldisk-g2",
"2016-datacenter-with-containers-g2",
"2016-datacenter-zhcn-g2",
"2019-datacenter-core-g2",
"2019-datacenter-core-smalldisk-g2",
"2019-datacenter-core-with-containers-g2",
"2019-datacenter-core-with-containers-smalldisk-g2",
"2019-datacenter-gensecond",
"2019-datacenter-smalldisk-g2",
"2019-datacenter-with-containers-g2",
"2019-datacenter-with-containers-smalldisk-g2",
"2019-datacenter-zhcn-g2",
"2022-datacenter-azure-edition",
"2022-datacenter-azure-edition-core",
"2022-datacenter-azure-edition-core-smalldisk",
"2022-datacenter-azure-edition-smalldisk",
"2022-datacenter-core-g2",
"2022-datacenter-core-smalldisk-g2",
"2022-datacenter-g2",
"2022-datacenter-smalldisk-g2"
],
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version."
}
},
"vmSize": {
"type": "string",
"metadata": {
"description": "Size of the virtual machine."
}
},
"subnetname": {
"type": "string",
"metadata": {
"description": "Subnet name for the Virtual Machine."
}
},
"virtualNetworkName": {
"type": "string",
"metadata": {
"description": "vNet name for the Virtual Machine."
}
},
"vNetResourceGroupName": {
"type": "string",
"metadata": {
"description": "Resource group name for the vNet."
}
},
"location": {
"type": "string",
"metadata": {
"description": "Location for all resources."
}
},
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the virtual machine."
}
},
"imageReference": {
"type": "string",
"metadata": {
"description": "Image reference for the virtual machine"
}
}
},
"variables": {
"nicName": "[parameters('vmName')]",
"subnetName": "[parameters('subnetName')]",
"virtualNetworkName": "[parameters('virtualNetworkName')]",
"vNetResourceGroupName": "[parameters('vNetResourceGroupName')]",
"imageReference": "[parameters('imageReference')]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2022-05-01",
"name": "[variables('nicName')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId(variables('vNetResourceGroupName'),'Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
}
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2022-03-01",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"id": "[variables('imageReference')]"
},
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment