Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasayukiOzawa/38bf0007dde6ede260febe8cf3c49275 to your computer and use it in GitHub Desktop.
Save MasayukiOzawa/38bf0007dde6ede260febe8cf3c49275 to your computer and use it in GitHub Desktop.
Tech Summit のデモ環境構築資材
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters" : {
"userImageStorageAccountName": {
"type": "string"
},
"userImageStorageContainerName" : {
"type" : "string",
"defaultValue" : "images"
},
"userImageVhdName" : {
"type" : "string",
"defaultValue" : "2016masterimage.vhd"
},
"adminUserName": {
"type": "string"
},
"adminPassword": {
"type": "string"
},
"osType" : {
"type" : "string",
"allowedValues" : [
"windows",
"linux"
],
"defaultValue": "windows"
},
"location": {
"type": "string",
"defaultValue" : "japanwest"
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_DS2_v2"
},
"publicIPAddressName": {
"type": "string",
"defaultValue" : "myPublicIP"
},
"vmName": {
"type": "string",
"defaultValue" : "myVM"
},
"virtualNetworkName":{
"type" : "string",
"defaultValue" : "myVNET"
},
"nicName":{
"type" : "string",
"defaultValue":"myNIC"
}
},
"variables": {
"addressPrefix":"10.0.0.0/16",
"subnet1Name": "Subnet-1",
"subnet2Name": "Subnet-2",
"subnet1Prefix" : "10.0.0.0/24",
"subnet2Prefix" : "10.0.1.0/24",
"publicIPAddressType" : "Dynamic",
"vnetID":"[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
"subnet1Ref" : "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
"userImageName" : "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',parameters('userImageStorageContainerName'),'/',parameters('userImageVhdName'))]",
"osDiskVhdName" : "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/vhds/',parameters('vmName'),'osDisk.vhd')]"
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddressName')]",
"location": "[parameters('location')]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnet1Name')]",
"properties" : {
"addressPrefix": "[variables('subnet1Prefix')]"
}
},
{
"name": "[variables('subnet2Name')]",
"properties" : {
"addressPrefix": "[variables('subnet2Prefix')]"
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('nicName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computername": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"osDisk" : {
"name" : "[concat(parameters('vmName'),'-osDisk')]",
"osType" : "[parameters('osType')]",
"caching" : "ReadWrite",
"createOption": "FromImage",
"image" : {
"uri" : "[variables('userImageName')]"
},
"vhd" : {
"uri" : "[variables('osDiskVhdName')]"
}
}
},
"networkProfile": {
"networkInterfaces" : [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',parameters('nicName'))]"
}
]
}
}
}
]
}
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters" : {
"userImageStorageAccountName": {
"type": "string"
},
"userImageStorageContainerName" : {
"type" : "string",
"defaultValue" : "images"
},
"userImageVhdName" : {
"type" : "string",
"defaultValue" : "myVMosDisk.vhd"
},
"adminUserName": {
"type": "string"
},
"adminPassword": {
"type": "string"
},
"osType" : {
"type" : "string",
"allowedValues" : [
"windows",
"linux"
],
"defaultValue": "windows"
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_DS2_v2"
},
"virtualNetworkName":{
"type" : "string",
"defaultValue" : "VNET"
},
"vmName": {
"type": "string",
"defaultValue" : "VM-"
},
"publicIPAddressName": {
"type": "string",
"defaultValue" : "VM-"
},
"nicName":{
"type" : "string",
"defaultValue":"VM-"
},
"startPrefix":{
"type": "int",
"defaultValue": 1
},
"count": {
"type": "int",
"defaultValue":3
}
},
"variables": {
"addressPrefix":"10.0.0.0/16",
"subnet1Name": "Subnet-1",
"subnet2Name": "Subnet-2",
"vmIp":11,
"subnet1Prefix" : "10.0.0.0/24",
"subnet2Prefix" : "10.0.1.0/24",
"publicIPAddressType" : "Dynamic",
"availabilitySetName": "SQL-AS-01",
"vnetID":"[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
"subnet1Ref" : "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
"userImageName" : "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',parameters('userImageStorageContainerName'),'/', parameters('userImageVhdName'))]",
"osDiskVhdName" : "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/vhds/')]"
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"DhcpOptions" : {
"DnsServers": [
"10.0.0.241"
]
},
"subnets": [
{
"name": "[variables('subnet1Name')]",
"properties" : {
"addressPrefix": "[variables('subnet1Prefix')]"
}
},
{
"name": "[variables('subnet2Name')]",
"properties" : {
"addressPrefix": "[variables('subnet2Prefix')]"
}
}
]
}
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[variables('availabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat(parameters('publicIPAddressName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2 ,'0'), '-PIP')]",
"location": "[resourceGroup().location]",
"copy":{
"name":"PublicIPCopy",
"count":"[parameters('count')]"
},
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(parameters('nicName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-NIC')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', concat(parameters('publicIPAddressName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'),'-PIP'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
],
"copy":{
"name":"NICCopy",
"count":"[parameters('count')]"
},
"properties": {
"ipConfigurations": [
{
"name": "[concat('VM-', padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'),'-IPCONFIG')]",
"properties": {
"privateIPAllocationMethod":"Static",
"privateIPAddress":"[concat('10.0.0.', add(variables('vmIp'),copyIndex()))]",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('publicIPAddressName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'),'-PIP'))]"
},
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', concat(parameters('nicName'), padLeft(add(copyIndex(), parameters('startPrefix')),2, '0'), '-NIC'))]",
"[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"
],
"copy":{
"name":"VMCopy",
"count":"[parameters('count')]"
},
"properties": {
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]"
},
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computername": "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'))]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"timeZone":"Tokyo Standard Time",
"enableAutomaticUpdates":false
}
},
"storageProfile": {
"osDisk" : {
"name" : "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-osDisk')]",
"osType" : "[parameters('osType')]",
"caching" : "ReadWrite",
"createOption": "FromImage",
"image" : {
"uri" : "[variables('userImageName')]"
},
"vhd" : {
"uri" : "[concat(variables('osDiskVhdName'), parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-osDisk.vhd')]"
}
},
"dataDisks":[
{
"name" : "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-dataDisk')]",
"diskSizeGB" : 1023,
"lun" : 0,
"vhd" : {
"uri" : "[concat(variables('osDiskVhdName'), parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-dataDisk.vhd')]"
},
"createOption": "Empty",
"caching" : "ReadOnly"
}
]
},
"networkProfile": {
"networkInterfaces" : [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('nicName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-NIC'))]"
}
]
}
}
}
]
}
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters" : {
"userImageStorageAccountName": {
"type": "string"
},
"userImageStorageContainerName" : {
"type" : "string",
"defaultValue" : "images"
},
"userImageVhdName" : {
"type" : "string",
"defaultValue" : "2016masterimage.vhd"
},
"adminUserName": {
"type": "string"
},
"adminPassword": {
"type": "string"
},
"osType" : {
"type" : "string",
"allowedValues" : [
"windows",
"linux"
],
"defaultValue": "windows"
},
"vmSize": {
"type": "string",
"defaultValue": "Basic_A1"
},
"virtualNetworkName":{
"type" : "string",
"defaultValue" : "VNET"
},
"vmName": {
"type": "string",
"defaultValue" : "DNS-"
},
"publicIPAddressName": {
"type": "string",
"defaultValue" : "DNS-"
},
"nicName":{
"type" : "string",
"defaultValue":"DNS-"
},
"startPrefix":{
"type": "int",
"defaultValue": 1
},
"count": {
"type": "int",
"defaultValue":1
}
},
"variables": {
"addressPrefix":"10.0.0.0/16",
"subnet1Name": "Subnet-1",
"subnet2Name": "Subnet-2",
"vmIp":241,
"subnet1Prefix" : "10.0.0.0/24",
"subnet2Prefix" : "10.0.1.0/24",
"publicIPAddressType" : "Dynamic",
"vnetID":"[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
"subnet1Ref" : "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
"userImageName" : "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',parameters('userImageStorageContainerName'),'/', parameters('userImageVhdName'))]",
"osDiskVhdName" : "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/vhds/')]"
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"DhcpOptions" : {
"DnsServers": [
"10.0.0.241"
]
},
"subnets": [
{
"name": "[variables('subnet1Name')]",
"properties" : {
"addressPrefix": "[variables('subnet1Prefix')]"
}
},
{
"name": "[variables('subnet2Name')]",
"properties" : {
"addressPrefix": "[variables('subnet2Prefix')]"
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat(parameters('publicIPAddressName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2 ,'0'), '-PIP')]",
"location": "[resourceGroup().location]",
"copy":{
"name":"PublicIPCopy",
"count":"[parameters('count')]"
},
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(parameters('nicName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-NIC')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', concat(parameters('publicIPAddressName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'),'-PIP'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
],
"copy":{
"name":"NICCopy",
"count":"[parameters('count')]"
},
"properties": {
"ipConfigurations": [
{
"name": "[concat('VM-', padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'),'-IPCONFIG')]",
"properties": {
"privateIPAllocationMethod":"Static",
"privateIPAddress":"[concat('10.0.0.', add(variables('vmIp'),copyIndex()))]",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(parameters('publicIPAddressName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'),'-PIP'))]"
},
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', concat(parameters('nicName'), padLeft(add(copyIndex(), parameters('startPrefix')),2, '0'), '-NIC'))]"
],
"copy":{
"name":"VMCopy",
"count":"[parameters('count')]"
},
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computername": "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'))]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"timeZone":"Tokyo Standard Time",
"enableAutomaticUpdates":false
}
},
"storageProfile": {
"osDisk" : {
"name" : "[concat(parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-osDisk')]",
"osType" : "[parameters('osType')]",
"caching" : "ReadWrite",
"createOption": "FromImage",
"image" : {
"uri" : "[variables('userImageName')]"
},
"vhd" : {
"uri" : "[concat(variables('osDiskVhdName'), parameters('vmName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-osDisk.vhd')]"
}
}
},
"networkProfile": {
"networkInterfaces" : [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(parameters('nicName'), padLeft(add(copyIndex(), parameters('startPrefix')), 2, '0'), '-NIC'))]"
}
]
}
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {
"lbipPrefix" : "10.0.0.",
"lbip" : 101,
"virtualNetworkName": "VNET",
"subnetName": "Subnet-1",
"loadBalancerName": "ENT-ILB-01",
"backendAddressPoolName" : "ENT-BE-01",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/', variables('subnetName'))]",
"lbID": "[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"frontEndIPConfigId": "[concat(variables('lbID'), '/frontendIPConfigurations/')]",
"lbProbeID": "[concat(variables('lbID'),'/probes/')]",
"backendAddressPoolId" : "[concat(variables('lbID'), '/backendAddressPools/', variables('backendAddressPoolName'))]",
"apiVersion": "2016-03-30"
},
"resources": [
{
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('loadBalancerName')]",
"type": "Microsoft.Network/loadBalancers",
"location": "[resourceGroup().location]",
"dependsOn": [],
"properties": {
"frontendIPConfigurations": [
{
"name": "[concat(variables('lbipPrefix'), variables('lbip'))]",
"properties": {
"PrivateIpAllocationMethod" : "Static",
"privateIpAddress" : "[concat(variables('lbipPrefix'), variables('lbip'))]",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
},
{
"name": "[concat(variables('lbipPrefix'), add(variables('lbip'), 1))]",
"properties": {
"PrivateIpAllocationMethod" : "Static",
"privateIpAddress" : "[concat(variables('lbipPrefix'), add(variables('lbip'), 1))]",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('backendAddressPoolName')]"
}
],
"loadBalancingRules": [
{
"name": "[concat(variables('lbipPrefix'), variables('lbip'))]",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(variables('frontEndIPConfigId'), variables('lbipPrefix'), variables('lbip'))]"
},
"BackendAddressPool" : {
"id" : "[variables('backendAddressPoolId')]"
},
"protocol": "tcp",
"frontendPort": 1433,
"backendPort": 1433,
"enableFloatingIP": true,
"probe": {
"id": "[concat(variables('lbProbeID'), '59998')]"
}
}
},
{
"name": "[concat(variables('lbipPrefix'), add(variables('lbip'), 1))]",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(variables('frontEndIPConfigId'), variables('lbipPrefix'), add(variables('lbip'), 1))]"
},
"BackendAddressPool" : {
"id" : "[variables('backendAddressPoolId')]"
},
"protocol": "tcp",
"frontendPort": 1433,
"backendPort": 1433,
"enableFloatingIP": true,
"probe": {
"id": "[concat(variables('lbProbeID'), '59999')]"
}
}
}
],
"probes": [
{
"name": "59998",
"properties": {
"protocol": "Tcp",
"port": 59998,
"intervalInSeconds": 5,
"numberOfProbes": 4
}
},
{
"name": "59999",
"properties": {
"protocol": "Tcp",
"port": 59999,
"intervalInSeconds": 5,
"numberOfProbes": 4
}
}
]
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {
"lbipPrefix" : "10.0.0.",
"lbip" : 111,
"virtualNetworkName": "VNET",
"subnetName": "Subnet-1",
"loadBalancerName": "ENT-ILB-02",
"backendAddressPoolName" : "ENT-BE-02",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/', variables('subnetName'))]",
"lbID": "[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"frontEndIPConfigId": "[concat(variables('lbID'), '/frontendIPConfigurations/')]",
"lbProbeID": "[concat(variables('lbID'),'/probes/')]",
"backendAddressPoolId" : "[concat(variables('lbID'), '/backendAddressPools/', variables('backendAddressPoolName'))]",
"apiVersion": "2016-03-30"
},
"resources": [
{
"apiVersion": "[variables('apiVersion')]",
"name": "[variables('loadBalancerName')]",
"type": "Microsoft.Network/loadBalancers",
"location": "[resourceGroup().location]",
"dependsOn": [],
"properties": {
"frontendIPConfigurations": [
{
"name": "[concat(variables('lbipPrefix'), variables('lbip'))]",
"properties": {
"PrivateIpAllocationMethod" : "Static",
"privateIpAddress" : "[concat(variables('lbipPrefix'), variables('lbip'))]",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('backendAddressPoolName')]"
}
],
"loadBalancingRules": [
{
"name": "[concat(variables('lbipPrefix'), variables('lbip'))]",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(variables('frontEndIPConfigId'), variables('lbipPrefix'), variables('lbip'))]"
},
"BackendAddressPool" : {
"id" : "[variables('backendAddressPoolId')]"
},
"protocol": "tcp",
"frontendPort": 1433,
"backendPort": 1433,
"enableFloatingIP": true,
"probe": {
"id": "[concat(variables('lbProbeID'), '59999')]"
}
}
}
],
"probes": [
{
"name": "59999",
"properties": {
"protocol": "Tcp",
"port": 59999,
"intervalInSeconds": 5,
"numberOfProbes": 4
}
}
]
}
}
]
}
$cred = Get-Credential
Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force
$Node = @("10.0.0.11", "10.0.0.12", "10.0.0.13")
$script = {
$DNSSuffix = "dat012.local"
if((Get-WindowsFeature -Name Failover-Clustering).InstallState -ne "Installed"){
Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools
}else{
Write-Output "Failover-Clustering Feature has Installed"
}
Set-ItemProperty registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name "NV Domain" -Value $DNSSuffix
Register-DnsClient
}
Invoke-Command -ComputerName $Node -ScriptBlock $script -Credential $cred
Invoke-Command -ComputerName $Node -ScriptBlock {Restart-Computer -Force} -Credential $cred
$ClusterNetworkName = "クラスター ネットワーク 1"
$IPResourceName = "クラスター IP アドレス"
Get-ClusterResource -Name $IPResourceName | Set-ClusterParameter `
-Multiple @{
Network=$ClusterNetworkName;`
Address="169.254.1.1";`
SubnetMask="255.255.255.255";`
OverrideAddressMatch=1;`
EnableDhcp=0
}
$cred = Get-Credential
Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force
$Node = @("10.0.0.11", "10.0.0.12", "10.0.0.13")
$Script = {
Import-Module SQLPS -DisableNameChecking
Enable-SQLAlwaysOn -ServerInstance $ENV:COMPUTERNAME -Force
New-NetFirewallRule -Name "SQL Server" -DisplayName "SQL Server" -Protocol "TCP" -LocalPort "1433" > $null
New-NetFirewallRule -Name "SQL Server AlwaysOn Endpoint" -DisplayName "SQL Server" -Protocol "TCP" -LocalPort "5022" > $null
New-NetFirewallRule -Name "SQL Server Probe (59998)" -DisplayName "SQL Server" -Protocol "TCP" -LocalPort "59998" > $null
New-NetFirewallRule -Name "SQL Server Probe (59999)" -DisplayName "SQL Server" -Protocol "TCP" -LocalPort "59999" > $null
}
Invoke-Command -ComputerName $Node -ScriptBlock $Script -Credential $cred
:CONNECT VM-01
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-01\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-01\SQLServiceUser]
GO
:CONNECT VM-02
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-02\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-02\SQLServiceUser]
GO
:CONNECT VM-03
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-03\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-03\SQLServiceUser]
GO
:CONNECT VM-01
CREATE AVAILABILITY GROUP [ENT-AG01-02]
WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY,
DB_FAILOVER = OFF,
DTC_SUPPORT = PER_DB)
FOR
REPLICA ON
N'VM-01' WITH (ENDPOINT_URL = N'TCP://VM-01.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL), SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL)),
N'VM-02' WITH (ENDPOINT_URL = N'TCP://VM-02.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL), SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL)),
N'VM-03' WITH (ENDPOINT_URL = N'TCP://VM-03.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL), SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL));
GO
ALTER AVAILABILITY GROUP [ENT-AG01-02] GRANT CREATE ANY DATABASE
:Connect VM-02
ALTER AVAILABILITY GROUP [ENT-AG01-02] JOIN;
GO
ALTER AVAILABILITY GROUP [ENT-AG01-02] GRANT CREATE ANY DATABASE
GO
:Connect VM-03
ALTER AVAILABILITY GROUP [ENT-AG01-02] JOIN;
GO
ALTER AVAILABILITY GROUP [ENT-AG01-02] GRANT CREATE ANY DATABASE
GO
:Connect VM-01
ALTER AVAILABILITY GROUP [ENT-AG01-01] ADD DATABASE [TESTDB];
GO
ALTER AVAILABILITY GROUP [ENT-AG01-01] MODIFY REPLICA ON N'VM-02' WITH (SEEDING_MODE= AUTOMATIC)
GO
:CONNECT VM-04
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-04\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-04\SQLServiceUser]
GO
:CONNECT VM-05
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-05\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-05\SQLServiceUser]
GO
:CONNECT VM-04
CREATE AVAILABILITY GROUP [ENT-AG02-01]
WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY,
DB_FAILOVER = OFF,
DTC_SUPPORT = PER_DB)
FOR
REPLICA ON
N'VM-04' WITH (ENDPOINT_URL = N'TCP://VM-04.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL), SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL)),
N'VM-05' WITH (ENDPOINT_URL = N'TCP://VM-05.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL), SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL));
GO
ALTER AVAILABILITY GROUP [ENT-AG02-01] GRANT CREATE ANY DATABASE
:Connect VM-05
ALTER AVAILABILITY GROUP [ENT-AG02-01] JOIN;
GO
ALTER AVAILABILITY GROUP [ENT-AG02-01] GRANT CREATE ANY DATABASE
GO
:CONNECT VM-06
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-06\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-06\SQLServiceUser]
GO
:CONNECT VM-07
USE [master]
GO
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (LISTENER_PORT = 5022)
FOR DATA_MIRRORING (ROLE = ALL, ENCRYPTION = REQUIRED ALGORITHM AES)
GO
CREATE LOGIN [VM-07\SQLServiceUser] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [VM-07\SQLServiceUser]
GO
:CONNECT VM-06
CREATE AVAILABILITY GROUP [STD-AG01-01]
WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY,
BASIC,
DB_FAILOVER = OFF,
DTC_SUPPORT = PER_DB)
FOR
REPLICA ON
N'VM-06' WITH (ENDPOINT_URL = N'TCP://VM-06.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL)),
N'VM-07' WITH (ENDPOINT_URL = N'TCP://VM-07.dat012.local:5022', SEEDING_MODE = AUTOMATIC, FAILOVER_MODE = AUTOMATIC, AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, SESSION_TIMEOUT = 10, BACKUP_PRIORITY = 50, PRIMARY_ROLE(ALLOW_CONNECTIONS = ALL));
GO
ALTER AVAILABILITY GROUP [STD-AG01-01] GRANT CREATE ANY DATABASE
:Connect VM-07
ALTER AVAILABILITY GROUP [STD-AG01-01] JOIN;
GO
ALTER AVAILABILITY GROUP [STD-AG01-01] GRANT CREATE ANY DATABASE
GO
USE [master]
GO
ALTER AVAILABILITY GROUP [STD-AG01-01]
ADD LISTENER N'STD-AG01-LN01' (
WITH IP
((N'10.0.0.122', N'255.255.255.0')
)
, PORT=1433);
GO
$ClusterNetworkName = "クラスター ネットワーク 1"
$IPResourceName = "ENT-AG01-LN01-IP"
$LBIP = "10.0.0.101"
Get-ClusterResource -Name $IPResourceName | Set-ClusterParameter `
-Multiple @{
Network=$ClusterNetworkName;`
Address=$LBIP;`
ProbePort="59998";`
SubnetMask="255.255.255.255";`
OverrideAddressMatch=1;`
EnableDhcp=0
}
$cred = Get-Credential
Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force
$Node = @("10.0.0.11", "10.0.0.12", "10.0.0.13", "10.0.0.14", "10.0.0.15", "10.0.0.16", "10.0.0.17")
$Script = {
$sqlinstancename = "MSSQL13.MSSQLSERVER"
$SQLBinPath = (Get-ItemProperty ([io.path]::combine("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server", $sqlinstancename, "Setup"))).SQLBinRoot
$param = @{
ExclusionExtension = "mdf", "ldf", "ndf" , "bak", "trn"
ExclusionProcess = (Get-Item (Join-Path $SQLBinPath "sqlservr.exe"))
ExclusionPath = "C:\Windows\Cluster"
}
Set-MpPreference @param
}
Invoke-Command -ComputerName $Node -ScriptBlock $script -Credential $cred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment