Created
November 3, 2021 08:39
-
-
Save aravindan-acct/f595a6be593afc67c61d8240c3339831 to your computer and use it in GitHub Desktop.
Keycloak deployment on Microsoft Azure
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": {"password": { | |
"type": "securestring", | |
"metadata": { | |
"description": "User Password for ssh access" | |
} | |
}, | |
"vmname": {"type": "string", | |
"metadata": { | |
"description": "name of the Linux system" | |
}} | |
}, | |
"variables": { | |
"vmname": "[parameters('vmname')]", | |
"vmstorage": "[toLower(concat(variables('vmname'),'labstorage'))]", | |
"vmnsg": "[concat(variables('vmname'),'-nsg')]", | |
"vnet": "[concat(variables('vmname'),'-VirtualNetwork')]", | |
"keycloaksubnet": "[concat(variables('vnet'),'-Subnet')]", | |
"vmnic": "[concat(variables('vmname'),'-NIC')]", | |
"vmpublicip": "[concat(variables('vmname'),'-PublicIP')]", | |
"osdisk": "[concat(variables('vmname'),'-OSDisk')]", | |
"customscript": "[concat(variables('vmname'),'/customScript1')]" | |
}, | |
"resources": [ | |
{ | |
"name": "[variables('vmstorage')]", | |
"type": "Microsoft.Storage/storageAccounts", | |
"apiVersion": "2021-04-01", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "[concat(variables('vmname'),'StorageAccount')]" | |
}, | |
"sku": { | |
"name": "Standard_LRS" | |
}, | |
"kind": "Storage" | |
}, | |
{ | |
"name": "[variables('vmpublicip')]", | |
"type": "Microsoft.Network/publicIPAddresses", | |
"apiVersion": "2020-11-01", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "PublicIPAddress" | |
}, | |
"properties": { | |
"publicIPAllocationMethod": "Dynamic", | |
"dnsSettings": { | |
"domainNameLabel": "[toLower(variables('vmname'))]" | |
} | |
} | |
}, | |
{ | |
"name": "[variables('vmnsg')]", | |
"type": "Microsoft.Network/networkSecurityGroups", | |
"apiVersion": "2020-11-01", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"securityRules": [ | |
{ | |
"name": "nsgRule1", | |
"properties": { | |
"description": "SSH Access", | |
"protocol": "Tcp", | |
"sourcePortRange": "*", | |
"destinationPortRange": "22", | |
"sourceAddressPrefix": "*", | |
"destinationAddressPrefix": "*", | |
"access": "Allow", | |
"priority": 100, | |
"direction": "Inbound" | |
} | |
}, | |
{ | |
"name": "nsgRule2", | |
"properties": { | |
"description": "Keycloak Auth port", | |
"protocol": "Tcp", | |
"sourcePortRange": "*", | |
"destinationPortRange": "443", | |
"sourceAddressPrefix": "*", | |
"destinationAddressPrefix": "*", | |
"access": "Allow", | |
"priority": 101, | |
"direction": "Inbound" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"name": "[variables('vnet')]", | |
"type": "Microsoft.Network/virtualNetworks", | |
"apiVersion": "2020-11-01", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('vmnsg'))]" | |
], | |
"tags": { | |
"displayName": "Keycloak-VirtualNetwork" | |
}, | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"10.0.0.0/16" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[variables('keycloaksubnet')]", | |
"properties": { | |
"addressPrefix": "10.0.0.0/24", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('vmnsg'))]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"name": "[variables('vmnic')]", | |
"type": "Microsoft.Network/networkInterfaces", | |
"apiVersion": "2020-11-01", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/publicIPAddresses', variables('vmpublicip'))]", | |
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnet'))]" | |
], | |
"tags": { | |
"displayName": "[variables('vmnic')]" | |
}, | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipConfig1", | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('vmpublicip'))]" | |
}, | |
"subnet": { | |
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnet'), variables('keycloaksubnet'))]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"name": "[variables('vmname')]", | |
"type": "Microsoft.Compute/virtualMachines", | |
"apiVersion": "2021-03-01", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/networkInterfaces', variables('vmnic'))]" | |
], | |
"tags": { | |
"displayName": "[variables('vmname')]" | |
}, | |
"properties": { | |
"hardwareProfile": { | |
"vmSize": "Standard_A2_v2" | |
}, | |
"osProfile": { | |
"computerName": "[toLower(variables('vmname'))]", | |
"adminUsername": "labuser", | |
"adminPassword": "[parameters('password')]" | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "Canonical", | |
"offer": "UbuntuServer", | |
"sku": "18.04-LTS", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"name": "[variables('osdisk')]", | |
"caching": "ReadWrite", | |
"createOption": "FromImage" | |
} | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('vmnic'))]" | |
} | |
] | |
}, | |
"diagnosticsProfile": { | |
"bootDiagnostics": { | |
"enabled": true, | |
"storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts/', toLower(variables('vmstorage')))).primaryEndpoints.blob]" | |
} | |
} | |
} | |
}, | |
{ | |
"name": "[variables('customscript')]", | |
"type": "Microsoft.Compute/virtualMachines/extensions", | |
"apiVersion": "2021-03-01", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "customScript1 for Linux VM" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Compute/virtualMachines', variables('vmname'))]" | |
], | |
"properties": { | |
"publisher": "Microsoft.Azure.Extensions", | |
"type": "CustomScript", | |
"typeHandlerVersion": "2.1", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"fileUris": [ | |
"https://raw.githubusercontent.com/aravindan-acct/keycloak_azure/main/scripts/customscript.sh" | |
] | |
}, | |
"protectedSettings": { | |
"commandToExecute": "nohup bash customscript.sh" | |
} | |
} | |
} | |
], | |
"outputs": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment