Created
February 15, 2021 17:28
-
-
Save krnese/86b13918a3f345be14e64cc35c164e59 to your computer and use it in GitHub Desktop.
DomainJoinVM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"vmSku": { | |
"type": "string", | |
"defaultValue": "Standard_D2_v2" | |
}, | |
"windowsOsVersion": { | |
"type": "string", | |
"defaultValue": "2019-Datacenter" | |
}, | |
"vmName": { | |
"type": "string" | |
}, | |
"vNetRgName": { | |
"type": "string" | |
}, | |
"vNetName": { | |
"type": "string" | |
}, | |
"vNetSubnetName": { | |
"type": "string" | |
}, | |
"adminUsername": { | |
"type": "string" | |
}, | |
"adminPwd": { | |
"type": "securestring" | |
}, | |
"domainFqdn": { | |
"type": "string" | |
}, | |
"domainJoinUser": { | |
"type": "string" | |
}, | |
"domainJoinUserPassword": { | |
"type": "string" | |
} | |
}, | |
"variables": { | |
"subnetId": "[concat(subscription().id, '/resourceGroups/', parameters('vNetRgName'), '/providers/Microsoft.Network/virtualNetworks/', parameters('vNetName'), '/subnets/', parameters('vNetSubnetName'))]", | |
"vNicName": "[concat(parameters('vmName'), '-vNic')]", | |
"domainJoinOption": "3" | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Network/networkInterfaces", | |
"apiVersion": "2020-05-01", | |
"name": "[variables('vNicName')]", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipconfig", | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"subnet": { | |
"id": "[variables('subnetId')]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Compute/virtualMachines", | |
"apiVersion": "2019-07-01", | |
"name": "[parameters('vmName')]", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/networkInterfaces', variables('vNicName'))]" | |
], | |
"properties": { | |
"hardwareProfile": { | |
"vmSize": "[parameters('vmSku')]" | |
}, | |
"osProfile": { | |
"computerName": "[parameters('vmName')]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"adminPassword": "[parameters('adminPwd')]" | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "MicrosoftWindowsServer", | |
"offer": "WindowsServer", | |
"sku": "[parameters('windowsOsVersion')]", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"name": "[concat(parameters('vmName'), 'osdisk')]", | |
"createOption": "FromImage", | |
"managedDisk": { | |
"storageAccountType": "StandardSSD_LRS" | |
}, | |
"caching": "ReadWrite" | |
} | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('vNicName'))]" | |
} | |
] | |
} | |
} | |
}, | |
{ | |
"type": "Microsoft.Compute/virtualMachines/extensions", | |
"apiVersion": "2019-07-01", | |
"name": "[concat(parameters('vmName'), '/', 'addj')]", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]" | |
], | |
"properties": { | |
"publisher": "Microsoft.Compute", | |
"type": "JsonADDomainExtension", | |
"typeHandlerVersion": "1.3", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"name": "[parameters('domainFqdn')]", | |
"user": "[concat(parameters('domainJoinUser'), '@', parameters('domainFqdn'))]", | |
"restart": "true", | |
"options": "[variables('domainJoinOption')]" | |
}, | |
"protectedSettings": { | |
"password": "[parameters('domainJoinUserPassword')]" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment