Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update/secure-hybrid-network #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions solutions/secure-hybrid-network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ For detailed information, see the Implement a secure hybrid network:

Clone this repo and then run the following commands to initiate the deployment. When prompted, enter values for an admin username and password. These values are used to log into the included virtual machines.

```azurecli-interactive
```bash
## Environment
LOCATION=eastus2
ONPREM_RESOURCEGROUP_NAME=rg-site-to-site-mock-prem-${LOCATION}
AZURE_NETWORK_RESOURCEGROUP_NAME=rg-site-to-site-azure-network-${LOCATION}

# Resources will be created on deployment region
cd solutions/secure-hybrid-network
az deployment sub create --location eastus --template-file azuredeploy.bicep
az deployment sub create -n secure-hybrid-network --location ${LOCATION} --template-file azuredeploy.bicep -p mocOnPremResourceGroup=${ONPREM_RESOURCEGROUP_NAME} azureNetworkResourceGroup=${AZURE_NETWORK_RESOURCEGROUP_NAME}
```

## Solution deployment parameters
Expand Down Expand Up @@ -61,7 +67,7 @@ az deployment sub create --location eastus --template-file azuredeploy.bicep
| spokeRoutes | object | Object representing user-defined routes for the spoke subnet. | tableName, routeNameFirewall |
| gatewayRoutes | object | Object representing user-defined routes for the gateway network. | tableName, routeNameFirewall |
| internalLoadBalancer | object | Object representing the configuration of the application load balancer. | name, backendName, fontendName, probeName |
| location | string | Location to be used for all resources. | null |
| location | string | Location to be used for all resources. | rg location |

**nestedtemplates/azure-network-local-gateway.json**

Expand All @@ -84,7 +90,7 @@ az deployment sub create --location eastus --template-file azuredeploy.bicep
| bastionHost | object | Object representing the configuration of the Bastion host. | name, subnetName, subnetPrefix, publicIPAddressName, nsgName |
| vmSize | string | Size of the load-balanced virtual machines. | Standard_A1_v2 |
| configureSitetosite | bool | Condition for configuring a site-to-site VPN connection. | true |
| location | string | Location to be used for all resources. | null |
| location | string | Location to be used for all resources. | rg location |

**nestedtemplates/mock-onprem-local-gateway.json**

Expand All @@ -96,7 +102,15 @@ az deployment sub create --location eastus --template-file azuredeploy.bicep
| gatewayIpAddress | string | Public IP address of the Azure virtual network gateway. | null |
| mocOnpremGatewayName | string | Name of the mock on-prem local network gateway. | null |
| localNetworkGateway | string | Name of the mock on-prem local network gateway. | local-gateway-moc-prem |
| location | string | Location to be used for all resources. | null |
| location | string | Location to be used for all resources. | rg location |


## Clean Up

```bash
az group delete --name ${ONPREM_RESOURCEGROUP_NAME} --yes
az group delete --name ${AZURE_NETWORK_RESOURCEGROUP_NAME} --yes
```

## Microsoft Open Source Code of Conduct

Expand Down
14 changes: 7 additions & 7 deletions solutions/secure-hybrid-network/azuredeploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ param adminUserName string
@description('The admin password for both the Windows and Linux virtual machines.')
@secure()
param adminPassword string
param resourceGrouplocation string = 'eastus'
param location string = deployment().location

resource mocOnPremResourceGroup_resource 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: mocOnPremResourceGroup
location: resourceGrouplocation
location: location
}

resource azureNetworkResourceGroup_resource 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: azureNetworkResourceGroup
location: resourceGrouplocation
location: location
}

module onPremMock 'nestedtemplates/mock-onprem-azuredeploy.bicep' = {
Expand All @@ -26,7 +26,7 @@ module onPremMock 'nestedtemplates/mock-onprem-azuredeploy.bicep' = {
params: {
adminUserName: adminUserName
adminPassword: adminPassword
location: resourceGrouplocation
location: location
}
}

Expand All @@ -36,7 +36,7 @@ module azureNetwork 'nestedtemplates/azure-network-azuredeploy.bicep' = {
params: {
adminUserName: adminUserName
adminPassword: adminPassword
location: resourceGrouplocation
location: location
}
}

Expand All @@ -48,7 +48,7 @@ module mockOnPremLocalGateway 'nestedtemplates/mock-onprem-local-gateway.bicep'
azureCloudVnetPrefix: azureNetwork.outputs.mocOnpremNetwork
spokeNetworkAddressPrefix: azureNetwork.outputs.spokeNetworkAddressPrefix
mocOnpremGatewayName: onPremMock.outputs.mocOnpremGatewayName
location: resourceGrouplocation
location: location
}
}

Expand All @@ -59,6 +59,6 @@ module azureNetworkLocalGateway 'nestedtemplates/azure-network-local-gateway.bic
azureCloudVnetPrefix: onPremMock.outputs.mocOnpremNetworkPrefix
gatewayIpAddress: onPremMock.outputs.vpnIp
azureNetworkGatewayName: azureNetwork.outputs.azureGatewayName
location: resourceGrouplocation
location: location
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ param internalLoadBalancer object = {
fontendName: 'lb-frontend'
probeName: 'lb-probe'
}
param location string
param location string = resourceGroup().location

var logAnalyticsWorkspaceName = 'la-${uniqueString(subscription().subscriptionId, resourceGroup().id)}'
var peering_name_hub_to_spoke = 'hub-to-spoke'
var peering_name_spoke_to_hub = 'spoke-to-hub'
var nicNameWebName = 'nic-web-server'
var vmNameWebName = 'vm-web-server'
var windowsOSVersion = '2012-R2-Datacenter'
Expand Down Expand Up @@ -386,15 +384,19 @@ resource spokeNetwork_name_Microsoft_Insights_default_logAnalyticsWorkspace 'Mic
}
}

resource vpnGateway_publicIPAddress 'Microsoft.Network/publicIPAddresses@2023-04-01' = if (configureSitetosite) {
resource vpnGateway_publicIPAddress 'Microsoft.Network/publicIPAddresses@2023-11-01' = if (configureSitetosite) {
name: vpnGateway.publicIPAddressName
location: location
sku: {
name: 'Standard'
tier: 'Regional'
}
properties: {
publicIPAllocationMethod: 'Dynamic'
publicIPAllocationMethod: 'Static'
}
}

resource vpnGatewayResource 'Microsoft.Network/virtualNetworkGateways@2023-04-01' = if (configureSitetosite) {
resource vpnGatewayResource 'Microsoft.Network/virtualNetworkGateways@2023-11-01' = if (configureSitetosite) {
name: vpnGateway.name
location: location
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param gatewayIpAddress string
param azureCloudVnetPrefix string
param azureNetworkGatewayName string
param localNetworkGatewayName string = 'local-gateway-azure-network'
param location string
param location string = resourceGroup().location

resource localNetworkGateway 'Microsoft.Network/localNetworkGateways@2023-04-01' = {
name: localNetworkGatewayName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ param bastionHost object = {
}
param vmSize string = 'Standard_A1_v2'
param configureSitetosite bool = true
param location string
param location string = resourceGroup().location

var nicNameWindowsName = 'nic-windows'
var vmNameWindowsName = 'vm-windows'
Expand Down Expand Up @@ -61,15 +61,19 @@ resource mocOnpremNetworkResource 'Microsoft.Network/virtualNetworks@2023-04-01'
}
}

resource mocOnpremGateway_publicIPAddress 'Microsoft.Network/publicIPAddresses@2023-04-01' = if (configureSitetosite) {
resource mocOnpremGateway_publicIPAddress 'Microsoft.Network/publicIPAddresses@2023-11-01' = if (configureSitetosite) {
name: mocOnpremGateway.publicIPAddressName
location: location
sku: {
name: 'Standard'
tier: 'Regional'
}
properties: {
publicIPAllocationMethod: 'Dynamic'
publicIPAllocationMethod: 'Static'
}
}

resource mocOnpremGatewayResource 'Microsoft.Network/virtualNetworkGateways@2023-04-01' = if (configureSitetosite) {
resource mocOnpremGatewayResource 'Microsoft.Network/virtualNetworkGateways@2023-11-01' = if (configureSitetosite) {
name: mocOnpremGateway.name
location: location
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param spokeNetworkAddressPrefix string
param gatewayIpAddress string
param mocOnpremGatewayName string
param localNetworkGateway string = 'local-gateway-moc-prem'
param location string
param location string = resourceGroup().location

resource localNetworkGateway_resource 'Microsoft.Network/localNetworkGateways@2023-04-01' = {
name: localNetworkGateway
Expand Down