|
| 1 | +--- |
| 2 | +title: Quickstart - Create a network security perimeter - Bicep |
| 3 | +description: Learn how to create a network security perimeter for an Azure resource using the Bicep. This example demonstrates the creation of a network security perimeter for an Azure Key Vault. |
| 4 | +author: mbender-ms |
| 5 | +ms.author: mbender |
| 6 | +ms.service: azure-private-link |
| 7 | +ms.topic: quickstart |
| 8 | +ms.date: 03/05/2024 |
| 9 | +ms.custom: subject-armqs, mode-arm, template-concept, devx-track-bicep |
| 10 | +#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. |
| 11 | +--- |
| 12 | + |
| 13 | +# Quickstart - Create a network security perimeter - Bicep |
| 14 | + |
| 15 | +In this quickstart, you'll use a Bicep template to create a network security perimeter for an Azure resource. This example demonstrates the creation of a network security perimeter for an Azure Key Vault. |
| 16 | + |
| 17 | +[!INCLUDE [About Bicep](~/reusable-content/ce-skilling/azure/includes/resource-manager-quickstart-bicep-introduction.md)] |
| 18 | + |
| 19 | +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). |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +You need 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). |
| 24 | + |
| 25 | +## Review the Bicep file |
| 26 | + |
| 27 | +This Bicep file creates a network security perimeter for an instance of Azure Key Vault. |
| 28 | + |
| 29 | +The Bicep file that this quickstart uses is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/network-security-perimeter-create/). |
| 30 | + |
| 31 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.sql/network-secuirty-perimeter-create/main.bicep"::: |
| 32 | + |
| 33 | + |
| 34 | +The Bicep file defines multiple Azure resources: |
| 35 | +- [**Microsoft.KeyVault/vaults**](/azure/templates/microsoft.keyvault/vaults): The instance of Key Vault with the sample database. |
| 36 | +- [**Microsoft.Network/networkSecurityPerimeters**](/azure/templates/microsoft.network/networksecurityperimeters): The network security perimeter that you use to access the instance of Key Vault. |
| 37 | +- [**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. |
| 38 | +- [**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. |
| 39 | +- [**Microsoft.Network/networkSecurityPerimeters/resourceAssociations**](/azure/templates/microsoft.network/networksecurityperimeters/resourceassociations): The resource associations that you use to access the instance of Key Vault. |
| 40 | + |
| 41 | +## Deploy the Bicep file |
| 42 | + |
| 43 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 44 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 45 | + |
| 46 | + # [CLI](#tab/CLI) |
| 47 | + |
| 48 | + ```azurecli |
| 49 | + az group create --name resource-group --location eastus |
| 50 | + az deployment group create --resource-group resource-group --template-file main.bicep --parameters |
| 51 | + networkSecurityPerimeterName=<network-security-perimeter-name> |
| 52 | + ``` |
| 53 | + # [PowerShell](#tab/PowerShell) |
| 54 | +
|
| 55 | + ```powershell |
| 56 | + New-AzResourceGroup -Name resource-group -Location eastus |
| 57 | + New-AzResourceGroupDeployment -ResourceGroupName resource-group -TemplateFile main.bicep -keyVaultName <key-vault-name> -networkSecurityPerimeterName <network-security-perimeter-name> |
| 58 | + ``` |
| 59 | +
|
| 60 | + When the deployment finishes, you should see a message indicating the deployment succeeded. |
| 61 | +
|
| 62 | +## Validate the deployment |
| 63 | +
|
| 64 | +> [!NOTE] |
| 65 | +> The Bicep file generates a unique name for the virtual machine myVm<b>{uniqueid}</b> resource, and for the SQL Database sqlserver<b>{uniqueid}</b> resource. Substitute your generated value for **{uniqueid}**. |
| 66 | +
|
| 67 | +## Clean up resources |
| 68 | +
|
| 69 | +When you no longer need the resources that you created with the private link service, delete the resource group. This removes the private link service and all the related resources. |
| 70 | +
|
| 71 | +# [CLI](#tab/CLI) |
| 72 | +
|
| 73 | +```azurecli-interactive |
| 74 | +az group delete --name resource-group |
| 75 | +``` |
| 76 | + |
| 77 | +# [PowerShell](#tab/PowerShell) |
| 78 | + |
| 79 | +```azurepowershell-interactive |
| 80 | +Remove-AzResourceGroup -Name resource-group |
| 81 | +``` |
| 82 | +--- |
0 commit comments