Skip to content

Commit 5e7fc0a

Browse files
committed
acrolynx
1 parent 75137c8 commit 5e7fc0a

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

articles/azure-resource-manager/bicep/deployment-script-vnet-private-endpoint.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Access a private virtual network from a Bicep deployment script
3-
description: Learn how to run and test Bicep deployment scripts in private networks.
2+
title: Run Bicep deployment script privately over a private endpoint
3+
description: Learn how to run Bicep deployment script privately over a private endpoint.
44
ms.custom: devx-track-bicep
55
ms.topic: how-to
66
ms.date: 06/04/2024
@@ -19,25 +19,29 @@ In this setup, the ACI created by deployment script runs within a virtual networ
1919
To run deployment scripts privately you need the following infrastructure as seen in the architecture diagram:
2020

2121
- Create a virtual network with two subnets:
22-
- A subnet for the private endpoint.
22+
- A subnet for the private endpoint.
2323
- A subnet for the ACI, this subnet needs a `Microsoft.ContainerInstance/containerGroups` delegation.
24-
- Create a storage account with public network access `disabled`
25-
- Create a private endpoint configured with the `file` sub-resource on the storage account
24+
- Create a storage account without public network access.
25+
- Create a private endpoint within the virtual network configured with the `file` sub-resource on the storage account.
2626
- Create a private DNS zone `privatelink.file.core.windows.net` and register the private endpoint IP address as an A record. Link the private DNS zone to the created virtual network.
2727
- Create a user-assigned managed identity with `Storage File Data Privileged Contributor` permissions on the storage account and specify it in the `identity` property in the deployment script resource. To assign the identity, see [Identity](/azure/azure-resource-manager/bicep/deployment-script-develop#identity).
28-
29-
The ACI is deployed implicitly by the deployment script resource.
28+
- The ACI resource is created automatically by the deployment script resource.
3029

3130
The following Bicep file configures the infrastructure required for running a deployment script privately:
3231

3332
```bicep
3433
@maxLength(10) // Required maximum length, because the storage account has a maximum of 26 characters
35-
param prefix string
34+
param namePrefix string
3635
param location string = resourceGroup().location
37-
param userAssignedIdentityName string = '${prefix}Identity'
38-
param storageAccountName string = '${prefix}stg${uniqueString(resourceGroup().id)}'
39-
param vnetName string = '${prefix}Vnet'
40-
param deploymentScriptName string = '${prefix}ds'
36+
param userAssignedIdentityName string = '${namePrefix}Identity'
37+
param storageAccountName string = '${namePrefix}stg${uniqueString(resourceGroup().id)}'
38+
param vnetName string = '${namePrefix}Vnet'
39+
param deploymentScriptName string = '${namePrefix}ds'
40+
41+
var roleNameStorageFileDataPrivilegedContributor = '69566ab7-960f-475b-8e7c-b3118f30c6bd'
42+
var vnetAddressPrefix = '192.168.4.0/23'
43+
var subnetEndpointAddressPrefix = '192.168.4.0/24'
44+
var subnetACIAddressPrefix = '192.168.5.0/24'
4145
4246
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
4347
name: userAssignedIdentityName
@@ -83,7 +87,7 @@ resource privateEndpoint 'Microsoft.Network/privateEndpoints@2023-05-01' = {
8387
}
8488
8589
resource storageFileDataPrivilegedContributorReference 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
86-
name: '69566ab7-960f-475b-8e7c-b3118f30c6bd' // Storage File Data Privileged Contributor
90+
name: roleNameStorageFileDataPrivilegedContributor
8791
scope: tenant()
8892
}
8993
@@ -131,7 +135,7 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023-05-01' = {
131135
properties:{
132136
addressSpace: {
133137
addressPrefixes: [
134-
'192.168.4.0/23'
138+
vnetAddressPrefix
135139
]
136140
}
137141
}
@@ -140,15 +144,15 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023-05-01' = {
140144
name: 'PrivateEndpointSubnet'
141145
properties: {
142146
addressPrefixes: [
143-
'192.168.4.0/24'
147+
subnetEndpointAddressPrefix
144148
]
145149
}
146150
}
147151
148152
resource containerInstanceSubnet 'subnets' = {
149153
name: 'ContainerInstanceSubnet'
150154
properties: {
151-
addressPrefix: '192.168.5.0/24'
155+
addressPrefix: subnetACIAddressPrefix
152156
delegations: [
153157
{
154158
name: 'containerDelegation'

0 commit comments

Comments
 (0)