Skip to content

Commit

Permalink
Update vnetPeering documentation and samples (#220)
Browse files Browse the repository at this point in the history
* Push updates

* Add newline

* Remove trailing spaces + update codetour

* Update infra-as-code/bicep/modules/vnetPeering/README.md

Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com>

* Update infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json

Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com>

Co-authored-by: Jack Tracey <41163455+jtracey93@users.noreply.github.com>
  • Loading branch information
jfaurskov and jtracey93 authored Apr 29, 2022
1 parent dfb4c64 commit 5601eec
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .vscode/tours/E2Etesttour.tour
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
},
{
"file": "tests/pipelines/bicep-build-to-validate.yml",
"description": "Run bicep deployment to create spoke to hub virtual network peering using previously created hub and spoke vnet.",
"description": "Run bicep deployment to create spoke to hub virtual network peering using previously created hub and spoke vnet. Note that command line parameters are added to override what's in the parameter file.",
"line": 237
},
{
Expand All @@ -328,7 +328,7 @@
},
{
"file": "tests/pipelines/bicep-build-to-validate.yml",
"description": "Run bicep deployment to create hub to spoke virtual network peering using previously created hub and spoke vnet.\r\n\r\n",
"description": "Run bicep deployment to create hub to spoke virtual network peering using previously created hub and spoke vnet. Note that command line parameters are added to override what's in the parameter file.",
"line": 246
},
{
Expand Down
69 changes: 68 additions & 1 deletion infra-as-code/bicep/modules/vnetPeering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,74 @@ The module will generate the following outputs:

## Deployment

Module is intended to be called from other modules as a reusable resource.
In this example, the remote spoke VNet will be peered with the Hub VNet in the Connectivity subscription.

> Note that the example configures the peering only one way, to complete the peering you will need to repeat the process with a separate parameter file with reverse parameters.
During the deployment step, we will take parameters provided in the example parameters file.

| Azure Cloud | Bicep template | Input parameters file |
| -------------- | ------------------- | ---------------------------------------- |
| All regions | vnetPeering.bicep | vnetPeering.parameters.example.json |

> For the examples below we assume you have downloaded or cloned the Git repo as-is and are in the root of the repository as your selected directory in your terminal of choice.
### Azure CLI
```bash
# For Azure global regions
# Set your Connectivity subscription ID as the the current subscription
$ConnectivitySubscriptionId="[your Connectivity subscription ID]"
az account set --subscription $ConnectivitySubscriptionId

az deployment group create \
--resource-group Spoke_Networking_POC \
--template-file infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep \
--parameters @infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json
```
OR
```bash
# For Azure China regions
# Set your Corp Connected Landing Zone subscription ID as the the current subscription
$ConnectivitySubscriptionId="[your Connectivity subscription ID]"
az account set --subscription $ConnectivitySubscriptionId

az deployment group create \
--resource-group Spoke_Networking_POC \
--template-file infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep \
--parameters @infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json
```

### PowerShell

```powershell
# For Azure global regions
# Set your Connectivity subscription ID as the the current subscription
$ConnectivitySubscriptionId = "[your Connectivity subscription ID]"
Select-AzSubscription -SubscriptionId $ConnectivitySubscriptionId
New-AzResourceGroupDeployment `
-ResourceGroupName Spoke_Networking_POC `
-TemplateFile infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep `
-TemplateParameterFile infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json
```
OR
```powershell
# For Azure China regions
# Set your Connectivity subscription ID as the the current subscription
$ConnectivitySubscriptionId = "[your Connectivity subscription ID]"
Select-AzSubscription -SubscriptionId $ConnectivitySubscriptionId
New-AzResourceGroupDeployment `
-ResourceGroupName Spoke_Networking_POC `
-TemplateFile infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep `
-TemplateParameterFile infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json
```

## Example output in Azure global regions

![Example Deployment Output](media/vnetPeeringExampleDeploymentOutput.png "Example Deployment Output in Azure global regions")

## Bicep Visualizer

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"parDestinationVirtualNetworkID": {
"value": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/HUB_Networking_POC/providers/Microsoft.Network/virtualNetworks/alz-hub-eastus"
},
"parSourceVirtualNetworkName": {
"value": "vnet-spoke"
},
"parDestinationVirtualNetworkName": {
"value": "alz-hub-eastus"
},
"parAllowVirtualNetworkAccess": {
"value": true
},
"parAllowForwardedTraffic": {
"value": true
},
"parAllowGatewayTransit": {
"value": false
},
"parUseRemoteGateways": {
"value": false
},
"parTelemetryOptOut": {
"value": false
}
}
}
4 changes: 2 additions & 2 deletions tests/pipelines/bicep-build-to-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
inputs:
targetType: 'inline'
script: |
az deployment group create --resource-group $(ResourceGroupName) --template-file infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep --parameters parDestinationVirtualNetworkID="/subscriptions/$(subscriptionId)/resourceGroups/$(ResourceGroupName)/providers/Microsoft.Network/virtualNetworks/alz-hub-eastus" parSourceVirtualNetworkName="vnet-spoke" parDestinationVirtualNetworkName="alz-hub-eastus"
az deployment group create --resource-group $(ResourceGroupName) --template-file infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep --parameters @infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json parDestinationVirtualNetworkID="/subscriptions/$(subscriptionId)/resourceGroups/$(ResourceGroupName)/providers/Microsoft.Network/virtualNetworks/alz-hub-eastus"
- task: Bash@3
displayName: Az CLI Deploy vNet Peer for PR hub to spoke
Expand All @@ -243,7 +243,7 @@ jobs:
inputs:
targetType: 'inline'
script: |
az deployment group create --resource-group $(ResourceGroupName) --template-file infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep --parameters parDestinationVirtualNetworkID="/subscriptions/$(subscriptionId)/resourceGroups/$(ResourceGroupName)/providers/Microsoft.Network/virtualNetworks/vnet-spoke" parSourceVirtualNetworkName="alz-hub-eastus" parDestinationVirtualNetworkName="vnet-spoke"
az deployment group create --resource-group $(ResourceGroupName) --template-file infra-as-code/bicep/modules/vnetPeering/vnetPeering.bicep --parameters @infra-as-code/bicep/modules/vnetPeering/vnetPeering.parameters.example.json parDestinationVirtualNetworkID="/subscriptions/$(subscriptionId)/resourceGroups/$(ResourceGroupName)/providers/Microsoft.Network/virtualNetworks/vnet-spoke" parSourceVirtualNetworkName="alz-hub-eastus" parDestinationVirtualNetworkName="vnet-spoke"
- job: bicep_cleanup
dependsOn: bicep_deploy
Expand Down

0 comments on commit 5601eec

Please sign in to comment.