|
| 1 | +targetScope = 'subscription' |
| 2 | +param location string |
| 3 | +param resourceGroupName string |
| 4 | +param randomGuid string = newGuid() |
| 5 | + |
| 6 | +// Resource Group |
| 7 | +module rg '../modules/Microsoft.Resources/resourceGroups/deploy.bicep' = { |
| 8 | + name: '${resourceGroupName}-${location}' |
| 9 | + params: { |
| 10 | + name: resourceGroupName |
| 11 | + location: location |
| 12 | + } |
| 13 | +} |
| 14 | + |
| 15 | +// vnet |
| 16 | +module virtualNetworks '../modules/Microsoft.Network/virtualNetworks/deploy.bicep' = { |
| 17 | + name: '${uniqueString(deployment().name)}-virtualNetworks' |
| 18 | + scope: resourceGroup(resourceGroupName) |
| 19 | + params: { |
| 20 | + // Required parameters |
| 21 | + location: location |
| 22 | + addressPrefixes: [ |
| 23 | + '10.0.0.0/16' |
| 24 | + ] |
| 25 | + name: 'vnet-01' |
| 26 | + subnets: [ |
| 27 | + { |
| 28 | + name: 'subnet-01' |
| 29 | + addressPrefix: '10.0.1.0/24' |
| 30 | + } |
| 31 | + ] |
| 32 | + } |
| 33 | + dependsOn: [ |
| 34 | + rg |
| 35 | + ] |
| 36 | +} |
| 37 | + |
| 38 | +module publicIp01 '../modules/Microsoft.Network/publicIPAddresses/deploy.bicep' = { |
| 39 | + name: 'pip-01' |
| 40 | + params: { |
| 41 | + name: 'pip-01' |
| 42 | + location: location |
| 43 | + publicIPAddressVersion: 'IPv4' |
| 44 | + skuTier: 'Regional' |
| 45 | + skuName: 'Basic' |
| 46 | + publicIPAllocationMethod: 'Dynamic' |
| 47 | + } |
| 48 | + scope: resourceGroup(resourceGroupName) |
| 49 | + dependsOn: [ |
| 50 | + rg |
| 51 | + ] |
| 52 | +} |
| 53 | + |
| 54 | +// basic lb |
| 55 | +module loadbalancer '../modules/Microsoft.Network/loadBalancers_custom/deploy.bicep' = { |
| 56 | + name: 'lb-basic01' |
| 57 | + scope: resourceGroup(resourceGroupName) |
| 58 | + params: { |
| 59 | + name: 'lb-basic-01' |
| 60 | + location: location |
| 61 | + frontendIPConfigurations: [ |
| 62 | + { |
| 63 | + name: 'fe-01' |
| 64 | + publicIPAddressId: publicIp01.outputs.resourceId |
| 65 | + } |
| 66 | + ] |
| 67 | + backendAddressPools: [ |
| 68 | + { |
| 69 | + name: 'be-01' |
| 70 | + } |
| 71 | + ] |
| 72 | + inboundNatRules: [] |
| 73 | + loadBalancerSku: 'Basic' |
| 74 | + loadBalancingRules: [ |
| 75 | + { |
| 76 | + backendAddressPoolName: 'be-01' |
| 77 | + backendPort: 80 |
| 78 | + frontendIPConfigurationName: 'fe-01' |
| 79 | + frontendPort: 80 |
| 80 | + idleTimeoutInMinutes: 4 |
| 81 | + loadDistribution: 'Default' |
| 82 | + name: 'rule-01' |
| 83 | + probeName: 'probe-01' |
| 84 | + protocol: 'Tcp' |
| 85 | + } |
| 86 | + ] |
| 87 | + probes: [ |
| 88 | + { |
| 89 | + intervalInSeconds: 5 |
| 90 | + name: 'probe-01' |
| 91 | + numberOfProbes: 2 |
| 92 | + port: '80' |
| 93 | + protocol: 'Tcp' |
| 94 | + } |
| 95 | + ] |
| 96 | + } |
| 97 | + dependsOn: [ |
| 98 | + rg |
| 99 | + ] |
| 100 | +} |
| 101 | + |
| 102 | +module storageAccounts '../modules/Microsoft.Storage/storageAccounts/deploy.bicep' = { |
| 103 | + name: 'bootdiag-storage-01' |
| 104 | + scope: resourceGroup(resourceGroupName) |
| 105 | + params: { |
| 106 | + name: 'bootdiag${uniqueString(deployment().name)}' |
| 107 | + location: location |
| 108 | + storageAccountSku: 'Standard_LRS' |
| 109 | + storageAccountKind: 'StorageV2' |
| 110 | + supportsHttpsTrafficOnly: true |
| 111 | + } |
| 112 | + dependsOn: [ |
| 113 | + rg |
| 114 | + ] |
| 115 | +} |
| 116 | + |
| 117 | +module availabilitySet '../modules/Microsoft.Compute/availabilitySets/deploy.bicep' = { |
| 118 | + scope: resourceGroup(resourceGroupName) |
| 119 | + name: 'as-01' |
| 120 | + params: { |
| 121 | + location: location |
| 122 | + name: 'as-01' |
| 123 | + } |
| 124 | + dependsOn: [ |
| 125 | + rg |
| 126 | + ] |
| 127 | +} |
| 128 | + |
| 129 | +module vm '../modules/Microsoft.Compute/virtualMachines_custom/deploy.bicep' = { |
| 130 | + scope: resourceGroup(resourceGroupName) |
| 131 | + name: 'vm-01' |
| 132 | + params: { |
| 133 | + name: 'vm-01' |
| 134 | + adminUsername: 'admin-vm' |
| 135 | + adminPassword: '${uniqueString(randomGuid)}rpP@340' |
| 136 | + availabilitySetResourceId: availabilitySet.outputs.resourceId |
| 137 | + location: location |
| 138 | + imageReference: { |
| 139 | + offer: 'WindowsServer' |
| 140 | + publisher: 'MicrosoftWindowsServer' |
| 141 | + sku: '2022-Datacenter' |
| 142 | + version: 'latest' |
| 143 | + } |
| 144 | + nicConfigurations: [ |
| 145 | + { |
| 146 | + location: location |
| 147 | + ipConfigurations: [ |
| 148 | + { |
| 149 | + name: 'ipconfig1' |
| 150 | + subnetResourceId: virtualNetworks.outputs.subnetResourceIds[0] |
| 151 | + loadBalancerBackendAddressPools: [ |
| 152 | + { |
| 153 | + id: loadbalancer.outputs.backendpools[0].id |
| 154 | + } |
| 155 | + ] |
| 156 | + } |
| 157 | + ] |
| 158 | + nicSuffix: 'nic' |
| 159 | + } |
| 160 | + ] |
| 161 | + osDisk: { |
| 162 | + createOption: 'fromImage' |
| 163 | + diskSizeGB: '128' |
| 164 | + managedDisk: { |
| 165 | + storageAccountType: 'Standard_LRS' |
| 166 | + } |
| 167 | + } |
| 168 | + osType: 'Windows' |
| 169 | + vmSize: 'Standard_DS1_v2' |
| 170 | + } |
| 171 | +} |
| 172 | + |
| 173 | +module vm2 '../modules/Microsoft.Compute/virtualMachines_custom/deploy.bicep' = { |
| 174 | + scope: resourceGroup(resourceGroupName) |
| 175 | + name: 'vm-02' |
| 176 | + params: { |
| 177 | + name: 'vm-02' |
| 178 | + adminUsername: 'admin-vm' |
| 179 | + availabilitySetResourceId: availabilitySet.outputs.resourceId |
| 180 | + adminPassword: '${uniqueString(randomGuid)}rpP@340' |
| 181 | + location: location |
| 182 | + imageReference: { |
| 183 | + offer: 'WindowsServer' |
| 184 | + publisher: 'MicrosoftWindowsServer' |
| 185 | + sku: '2022-Datacenter' |
| 186 | + version: 'latest' |
| 187 | + } |
| 188 | + nicConfigurations: [ |
| 189 | + { |
| 190 | + location: location |
| 191 | + ipConfigurations: [ |
| 192 | + { |
| 193 | + name: 'ipconfig1' |
| 194 | + subnetResourceId: virtualNetworks.outputs.subnetResourceIds[0] |
| 195 | + loadBalancerBackendAddressPools: [] |
| 196 | + } |
| 197 | + ] |
| 198 | + nicSuffix: 'nic' |
| 199 | + } |
| 200 | + ] |
| 201 | + osDisk: { |
| 202 | + createOption: 'fromImage' |
| 203 | + diskSizeGB: '128' |
| 204 | + managedDisk: { |
| 205 | + storageAccountType: 'Standard_LRS' |
| 206 | + } |
| 207 | + } |
| 208 | + osType: 'Windows' |
| 209 | + vmSize: 'Standard_DS1_v2' |
| 210 | + } |
| 211 | +} |
0 commit comments