DEV Community

Cover image for Isolate and Connect Your Applications with Azure Virtual Networks and Subnets (Part 1)
Jimi
Jimi

Posted on • Updated on

Isolate and Connect Your Applications with Azure Virtual Networks and Subnets (Part 1)

Introduction:

Imagine you have a critical application that requires isolation from the public internet and secure communication with other internal resources. Azure virtual networks and subnets provide the perfect solution to achieve this. We'll guide you through creating virtual networks with peered subnets, enabling private and secure communication between your applications.

Creating the Virtual Networks:

  1. Search and Create: Start by searching for "Virtual Networks" in the Azure portal search bar. Click "Create" to initiate the virtual network creation process.

    Clicking Create on Virtual Networks

  2. Resource Group and Naming: Create a resource group in the East US region to organize your resources. Provide a descriptive name for your virtual network, such as "app-vnet". (The image uses Canada Central, but select East US).

    Configure the details for the network

  3. Address Space: Under the "IP Addresses" tab, define the IPv4 address space for your virtual network. A common private address range is 10.1.0.0/16, which provides a good amount of usable IP addresses.

    Changing the default subnet

  4. Subnet Configuration: Click the "Edit" icon for the default subnet. Assign a meaningful name like "frontendSubnet" and configure the address range. Use a subnet mask of /24 (255.255.255.0) to create a subnet with 254 usable IP addresses. For example, you can use the starting IP address 10.1.0.0 for the frontend subnet. This allocates IP addresses from 10.1.0.0 to 10.1.0.255 for your frontend resources.

    Editing the subnet

  5. Creating the Backend Subnet: Click "Add a subnet" and configure another subnet named "backendSubnet". Assign a non-overlapping address range within the virtual network's space. For instance, you can use 10.1.1.0/24.

    Both subnets

  6. Review and Create: Once you've defined both subnets, click "Review + create" to validate and deploy the virtual network.

Creating the Second Virtual Network:

Follow steps 1-6 above to create a second virtual network for additional resources or functionalities. Here's an example configuration:

  • Resource Group: Use the same resource group
  • Name: Descriptive name, such as "hub-vnet" (for a hub virtual network)
  • Address Space: Choose a non-overlapping address space from the available private ranges. For example, you can use 10.0.0.0/16.
  • Subnet Configuration: Define subnets specific to the resources you plan to deploy in this virtual network.

Creating the second virtual network

Peering the Virtual Networks:

  1. Navigate and Select: Go to the first virtual network you created and navigate to the "Peerings" section. Click on "Add" to initiate the peering configuration.

    Finding Peerings on the first vnet

  2. Peering Details: Provide a descriptive name for the peering connection, such as "app-vnet-to-hub-vnet" (assuming the second network is for a hub).

  3. Virtual Network Selection: Choose the virtual network you want to peer with from the "Virtual network" dropdown menu. In this case, select the second virtual network you just created.

  4. Remote Peering: Define a name for the remote peering connection from the target virtual network's perspective. For example, "hub-vnet-to-app-vnet".

  5. Verification: Once configured, click "Save" to establish the peering connection. You can then verify the successful peering status in the Azure portal.

Configuring the peering connection

Confirming the peering connection

Conclusion

By following these steps, you'll have created isolated virtual networks with subnets for your applications. The peered connection allows secure communication between your frontend and backend resources.

In the next post we'll take a look at using network security groups and application security groups to enhance the security of the web application.

Top comments (0)