You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- An Azure account with an active subscription. You can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
@@ -410,6 +412,274 @@ The VMs take a few minutes to create. After Azure creates each VM, the Azure CLI
410
412
411
413
### [ARM](#tab/arm)
412
414
415
+
## Review the template
416
+
417
+
The template that you use in this quickstart is from [Azure Quickstart Templates](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.network/vnet-two-subnets/azuredeploy.json).
The template defines the following Azure resources:
422
+
423
+
-[Microsoft.Network/virtualNetworks](/azure/templates/microsoft.network/virtualnetworks): Create a virtual network.
424
+
-[Microsoft.Network/virtualNetworks/subnets](/azure/templates/microsoft.network/virtualnetworks/subnets): Create a subnet.
425
+
426
+
## Deploy the template
427
+
428
+
Deploy the Resource Manager template to Azure:
429
+
430
+
1. Select **Deploy to Azure** to sign in to Azure and open the template. The template creates a virtual network with two subnets.
431
+
432
+
:::image type="content" source="~/reusable-content/ce-skilling/azure/media/template-deployments/deploy-to-azure-button.svg" alt-text="Button to deploy the Resource Manager template to Azure." border="false" link="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.network%2Fvnet-two-subnets%2Fazuredeploy.json":::
433
+
434
+
1. In the portal, on the **Create a Virtual Network with two Subnets** page, enter or select the following values:
435
+
-**Resource group**: Select **Create new**, enter **CreateVNetQS-rg** for the resource group name, and then select **OK**.
436
+
-**Virtual Network Name**: Enter a name for the new virtual network.
437
+
1. Select **Review + create**, and then select **Create**.
438
+
1. When deployment finishes, select the **Go to resource** button to review the resources that you deployed.
439
+
440
+
## Review deployed resources
441
+
442
+
Explore the resources that you created with the virtual network by browsing through the settings panes for **VNet1**:
443
+
444
+
- The **Overview** tab shows the defined address space of **10.0.0.0/16**.
445
+
446
+
- The **Subnets** tab shows the deployed subnets of **Subnet1** and **Subnet2** with the appropriate values from the template.
447
+
448
+
To learn about the JSON syntax and properties for a virtual network in a template, see [Microsoft.Network/virtualNetworks](/azure/templates/microsoft.network/virtualnetworks).
449
+
450
+
### [Bicep](#tab/bicep)
451
+
452
+
## Create the virtual network and VMs
453
+
454
+
This quickstart uses the [Two VMs in VNET](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.compute/2-vms-internal-load-balancer/main.bicep) Bicep template from [Azure Resource Manager Quickstart Templates](https://github.com/Azure/azure-quickstart-templates) to create the virtual network, resource subnet, and VMs. The Bicep template defines the following Azure resources:
455
+
456
+
-[Microsoft.Network virtualNetworks](/azure/templates/microsoft.network/virtualnetworks): Creates an Azure virtual network.
457
+
-[Microsoft.Network virtualNetworks/subnets](/azure/templates/microsoft.network/virtualnetworks/subnets): Creates a subnet for the VMs.
458
+
-[Microsoft.Compute virtualMachines](/azure/templates/microsoft.compute/virtualmachines): Creates the VMs.
459
+
-[Microsoft.Compute availabilitySets](/azure/templates/microsoft.compute/availabilitysets): Creates an availability set.
1. Save the Bicep file to your local computer as *main.bicep*.
471
+
1. Deploy the Bicep file by using either the Azure CLI or Azure PowerShell:
472
+
473
+
### CLI
474
+
475
+
```azurecli
476
+
az group create \
477
+
--name TestRG \
478
+
--location eastus
479
+
480
+
az deployment group create \
481
+
--resource-group TestRG \
482
+
--template-file main.bicep
483
+
```
484
+
485
+
### PowerShell
486
+
487
+
```azurepowershell
488
+
$rgParams = @{
489
+
Name = 'TestRG'
490
+
Location = 'eastus'
491
+
}
492
+
New-AzResourceGroup @rgParams
493
+
494
+
$deploymentParams = @{
495
+
ResourceGroupName = 'TestRG'
496
+
TemplateFile = 'main.bicep'
497
+
}
498
+
New-AzResourceGroupDeployment @deploymentParams
499
+
```
500
+
501
+
When the deployment finishes, a message indicates that the deployment succeeded.
502
+
503
+
## Deploy Azure Bastion
504
+
505
+
Bastion uses your browser to connect to VMs in your virtual network over Secure Shell (SSH) or Remote Desktop Protocol (RDP) by using their private IP addresses. The VMs don't need public IP addresses, client software, or special configuration. For more information about Bastion, see [What is Azure Bastion?](~/articles/bastion/bastion-overview.md).
Use the [Azure Bastion as a Service](https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.network/azure-bastion/main.bicep) Bicep template from [Azure Resource Manager Quickstart Templates](https://github.com/Azure/azure-quickstart-templates) to deploy and configure Bastion in your virtual network. This Bicep template defines the following Azure resources:
511
+
512
+
- [Microsoft.Network virtualNetworks/subnets](/azure/templates/microsoft.network/virtualnetworks/subnets): Creates an **AzureBastionSubnet** subnet.
513
+
- [Microsoft.Network bastionHosts](/azure/templates/microsoft.network/bastionhosts): Creates the Bastion host.
514
+
- [Microsoft.Network publicIPAddresses](/azure/templates/microsoft.network/publicipaddresses): Creates a public IP address for the Bastion host.
515
+
- [Microsoft Network networkSecurityGroups](/azure/templates/microsoft.network/networksecuritygroups): Controls the settings for network security groups.
1. Deploy the Bicep file by using either the Azure CLI or Azure PowerShell:
559
+
560
+
#### CLI
561
+
562
+
```azurecli
563
+
az deployment group create \
564
+
--resource-group TestRG \
565
+
--template-file bastion.bicep
566
+
```
567
+
568
+
### PowerShell
569
+
570
+
```azurepowershell
571
+
$deploymentParams = @{
572
+
ResourceGroupName = 'TestRG'
573
+
TemplateFile = 'bastion.bicep'
574
+
}
575
+
New-AzResourceGroupDeployment @deploymentParams
576
+
```
577
+
578
+
When the deployment finishes, a message indicates that the deployment succeeded.
579
+
580
+
> [!NOTE]
581
+
> VMs in a virtual network with a Bastion host don't need public IP addresses. Bastion provides the public IP, and the VMs use private IPs to communicate within the network. You can remove the public IPs from any VMs in Bastion-hosted virtual networks. For more information, see [Dissociate a public IP address from an Azure VM](ip-services/remove-public-ip-address-vm.md).
582
+
583
+
## Review deployed resources
584
+
585
+
Use the Azure CLI, Azure PowerShell, or the Azure portal to review the deployed resources:
586
+
587
+
### CLI
588
+
589
+
```azurecli
590
+
az resource list --resource-group TestRG
591
+
```
592
+
593
+
### PowerShell
594
+
595
+
```azurepowershell
596
+
Get-AzResource -ResourceGroupName TestRG
597
+
```
598
+
599
+
### Portal
600
+
601
+
1. In the [Azure portal](https://portal.azure.com), search for and select **resource groups**. On the **Resource groups** page, select **TestRG** from the list of resource groups.
602
+
603
+
1. On the **Overview** page for **TestRG**, review all the resources that you created, including the virtual network, the two VMs, and the Bastion host.
604
+
605
+
1. Select the **VNet** virtual network. On the **Overview** page for **VNet**, note the defined address space of **10.0.0.0/16**.
606
+
607
+
1. On the left menu, select **Subnets**. On the **Subnets** page, note the deployed subnets of **backendSubnet** and **AzureBastionSubnet** with the assigned values from the Bicep files.
608
+
609
+
### [Terraform](#tab/terraform)
610
+
611
+
The script uses the Azure Resource Manager (`azurerm`) provider to interact with Azure resources. It uses the Random (`random`) provider to generate random pet names for the resources.
612
+
613
+
The script creates the following resources:
614
+
615
+
- A resource group: A container that holds related resources for an Azure solution.
616
+
617
+
- A virtual network: A fundamental building block for your private network in Azure.
618
+
619
+
- Two subnets: Segments of a virtual network's IP address range where you can place groups of isolated resources.
620
+
621
+
:::image type="content" source="./media/quick-create-bicep/virtual-network-bicep-resources.png" alt-text="Diagram of resources created in the virtual network quickstart." lightbox="./media/quick-create-bicep/virtual-network-bicep-resources.png":::
> The sample code for this article is in the [Azure Terraform GitHub repo](https://github.com/Azure/terraform/tree/master/quickstart/101-virtual-network-create-two-subnets). You can view the log file that contains the [test results from current and previous versions of Terraform](https://github.com/Azure/terraform/tree/master/quickstart/101-virtual-network-create-two-subnets/TestRecord.md).
629
+
>
630
+
> For more articles and sample code that show how to use Terraform to manage Azure resources, see the [documentation page for Terraform on Azure](/azure/terraform).
631
+
632
+
1. Create a directory in which to test and run the sample Terraform code, and make it the current directory.
633
+
634
+
1. Create a file named *main.tf* and insert the following code:
0 commit comments