Monday, December 27, 2021

Deploy an Azure hybrid network with Bicep

Use Bicep to deploy a mock data center connected to Azure hub and spoke

Have you ever needed a mock hybrid environment for learning or testing? 

If so, you've found the place. 

I created this Bicep template to deploy a mock data center connected to a hub and spoke vnet because time and time again, I find myself needing a test environment that represents a basic hybrid network for learning and or testing Azure services such as private link. So, fed up with deploying this environment manually, I decided to author a Bicep template to do so.

What does the template deploy?

The template deploys the following.

hub and spoke environment

  • A hub and spoke vnet peered together
  • An Azure firewall, deployed in the hub
  • A VPN Gateway, deployed in the hub
  • A route table applied to workload subnets that points the default route (0.0.0.0/0) to the Azure firewall
data center environment
  • A data center vnet

  • A VPN gateway
Lastly, the template creates a tunnel between the gateways in the dc and hub vnets.

In the end, this is what it will deploy. It's rudimentary, but effective. 


The code repository


Run the code

I've been using the Azure CLI lately. I like its efficiency with Azure more than PowerShell (which I still know and love). Unfortunately, and surprisingly, the Azure CLI doesn't support deploying remote Bicep files (source) yet. So, fork and or download the Bicep file locally or via Azure CloudShell.
Create a resource group

  • az group create --location [region] --name [yourRgName]
Run Bicep
  • az deployment group create --resource-group [yourRgName] --template-file .\main.bicep --parameters rgName=[yourRgName]

(I'm sure there are optimizations in the Bicep code. I have limited parameters to keep it simple. I welcome any input)

Summary

Well, that's it. The code will deploy the infrastructure in roughly ~45 minutes. Your experience will vary. The VPN gateways and Azure firewall take a bit of time. Just be patient and check the deployment status. 


I hope you found this helpful!


Reduce latency on Azure with Accelerated Networking

With Azure's accelerated networking feature, you can greatly reduce latency and improve the performance of virtual machines. In this blo...