|
| 1 | +--- |
| 2 | +title: Quickstart - Create a network security perimeter - Bicep |
| 3 | +titleSuffix: Azure Private Link |
| 4 | +description: Learn how to create a network security perimeter for an Azure resource using Bicep. This example demonstrates the creation of a network security perimeter for an Azure Key Vault. |
| 5 | +author: mbender-ms |
| 6 | +ms.author: mbender |
| 7 | +ms.service: azure-private-link |
| 8 | +ms.topic: quickstart |
| 9 | +ms.date: 03/07/2025 |
| 10 | +ms.custom: subject-armqs, mode-arm, template-concept, devx-track-bicep |
| 11 | +#CustomerIntent: As a network administrator, I want to create a network security perimeter for an Azure resource in the Bicep, so that I can control the network traffic to and from the resource. |
| 12 | +--- |
| 13 | + |
| 14 | +# Quickstart - Create a network security perimeter - Bicep |
| 15 | + |
| 16 | +Get started with network security perimeter by creating a network security perimeter for an Azure Key Vault using Bicep. A [network security perimeter](network-security-perimeter-concepts.md) allows [Azure Platform as a Service (PaaS)](./network-security-perimeter-concepts.md#onboarded-private-link-resources) resources to communicate within an explicit trusted boundary. You create and update a PaaS resource's association in a network security perimeter profile. Then you create and update network security perimeter access rules. When you're finished, you delete all resources created in this quickstart. |
| 17 | + |
| 18 | +[!INCLUDE [About Bicep](~/reusable-content/ce-skilling/azure/includes/resource-manager-quickstart-bicep-introduction.md)] |
| 19 | + |
| 20 | +You can also create a network security perimeter by using the [Azure portal](create-network-security-perimeter-portal.md), [Azure PowerShell](create-network-security-perimeter-powershell.md), or the [Azure CLI](create-network-security-perimeter-cli.md). |
| 21 | + |
| 22 | +[!INCLUDE [network-security-perimeter-preview-message](../../includes/network-security-perimeter-preview-message.md)] |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +- An Azure account with an active subscription. If you don't already have an Azure account, [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 27 | + |
| 28 | +[!INCLUDE [network-security-perimeter-add-preview](../../includes/network-security-perimeter-add-preview.md)] |
| 29 | + |
| 30 | +## Review the Bicep file |
| 31 | + |
| 32 | +This Bicep file creates a network security perimeter for an instance of Azure Key Vault. |
| 33 | + |
| 34 | +The Bicep file that this quickstart uses is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/network-security-perimeter-create/). |
| 35 | + |
| 36 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.network/network-security-perimeter-create/main.bicep"::: |
| 37 | + |
| 38 | + |
| 39 | +The Bicep file defines multiple Azure resources: |
| 40 | + |
| 41 | +- [**Microsoft.KeyVault/vaults**](/azure/templates/microsoft.keyvault/vaults): The instance of Key Vault with the sample database. |
| 42 | +- [**Microsoft.Network/networkSecurityPerimeters**](/azure/templates/microsoft.network/networksecurityperimeters): The network security perimeter that you use to access the instance of Key Vault. |
| 43 | +- [**Microsoft.Network/networkSecurityPerimeters/profiles**](/azure/templates/microsoft.network/networksecurityperimeters/profiles): The network security perimeter profile that you use to access the instance of Key Vault. |
| 44 | +- [**Microsoft.Network/networkSecurityPerimeters/profiles/accessRules**](/azure/templates/microsoft.network/networksecurityperimeters/profiles/accessrules): The access rules that you use to access the instance of Key Vault. |
| 45 | +- [**Microsoft.Network/networkSecurityPerimeters/resourceAssociations**](/azure/templates/microsoft.network/networksecurityperimeters/resourceassociations): The resource associations that you use to access the instance of Key Vault. |
| 46 | + |
| 47 | +## Deploy the Bicep file |
| 48 | + |
| 49 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 50 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 51 | + |
| 52 | + # [CLI](#tab/CLI) |
| 53 | + |
| 54 | + ```azurecli |
| 55 | + az group create --name resource-group --location eastus |
| 56 | + az deployment group create --resource-group resource-group --template-file main.bicep --parameters |
| 57 | + networkSecurityPerimeterName=<network-security-perimeter-name> |
| 58 | + ``` |
| 59 | + # [PowerShell](#tab/PowerShell) |
| 60 | +
|
| 61 | + ```powershell |
| 62 | + New-AzResourceGroup -Name resource-group -Location eastus |
| 63 | + New-AzResourceGroupDeployment -ResourceGroupName resource-group -TemplateFile main.bicep |
| 64 | + ``` |
| 65 | +
|
| 66 | + When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 67 | +
|
| 68 | +## Validate the deployment |
| 69 | +
|
| 70 | +1. Sign into the Azure portal. |
| 71 | +1. Enter **Network security perimeter** in the search box at the top of the portal. Select **Network security perimeters** in the search results. |
| 72 | +1. Select the **networkPerimeter** resource from the list of network security perimeters. |
| 73 | +1. Verify that the **networkPerimeter** resource is created successfully. The **Overview** page shows the details of the network security perimeter, including the profiles, associated resources, and Policy assignments. |
| 74 | +
|
| 75 | +## Clean up resources |
| 76 | +
|
| 77 | +When you no longer need the resources that you created with the network security perimeter service, delete the resource group. This removes the network security perimeter service and all the related resources. |
| 78 | +
|
| 79 | +# [CLI](#tab/CLI) |
| 80 | +
|
| 81 | +```azurecli-interactive |
| 82 | +az group delete --name resource-group |
| 83 | +``` |
| 84 | + |
| 85 | +# [PowerShell](#tab/PowerShell) |
| 86 | + |
| 87 | +```azurepowershell-interactive |
| 88 | +Remove-AzResourceGroup -Name resource-group |
| 89 | +``` |
| 90 | +--- |
| 91 | + |
| 92 | +[!INCLUDE [network-security-perimeter-delete-resources](../../includes/network-security-perimeter-delete-resources.md)] |
| 93 | + |
| 94 | +## Next steps |
| 95 | + |
| 96 | +> [!div class="nextstepaction"] |
| 97 | +> [Diagnostic logging for Azure Network Security Perimeter](./network-security-perimeter-diagnostic-logs.md) |
0 commit comments