@@ -244,6 +244,9 @@ param publicNetworkAccess string = 'Enabled'
244
244
@description ('Add a private endpoints for network connectivity' )
245
245
param usePrivateEndpoint bool = false
246
246
247
+ @description ('Use a P2S VPN Gateway for secure access to the private endpoints' )
248
+ param useVpnGateway bool = false
249
+
247
250
@description ('Id of the user or app to assign application roles' )
248
251
param principalId string = ''
249
252
@@ -529,7 +532,8 @@ module containerApps 'core/host/container-apps.bicep' = if (deploymentTarget ==
529
532
containerAppsEnvironmentName : acaManagedEnvironmentName
530
533
containerRegistryName : '${containerRegistryName }${resourceToken }'
531
534
logAnalyticsWorkspaceResourceId : useApplicationInsights ? monitoring .outputs .logAnalyticsWorkspaceId : ''
532
- virtualNetworkSubnetId : usePrivateEndpoint ? isolation .outputs .appSubnetId : ''
535
+ subnetResourceId : usePrivateEndpoint ? isolation .outputs .appSubnetId : ''
536
+ usePrivateIngress : usePrivateEndpoint
533
537
}
534
538
}
535
539
@@ -542,8 +546,8 @@ module acaBackend 'core/host/container-app-upsert.bicep' = if (deploymentTarget
542
546
acaIdentity
543
547
]
544
548
params : {
545
- name : !empty (backendServiceName ) ? backendServiceName : '${abbrs .webSitesContainerApps }backend- ${resourceToken }'
546
- location : location
549
+ name : !empty (backendServiceName ) ? backendServiceName : '${abbrs .webSitesContainerApps }backend${resourceToken }'
550
+ location : 'westus2'
547
551
identityName : (deploymentTarget == 'containerapps' ) ? acaIdentityName : ''
548
552
exists : webAppExists
549
553
workloadProfile : azureContainerAppsWorkloadProfile
@@ -554,7 +558,7 @@ module acaBackend 'core/host/container-app-upsert.bicep' = if (deploymentTarget
554
558
targetPort : 8000
555
559
containerCpuCoreCount : '1.0'
556
560
containerMemory : '2Gi'
557
- containerMinReplicas : 0
561
+ containerMinReplicas : 1
558
562
allowedOrigins : allowedOrigins
559
563
env : union (appEnvVariables , {
560
564
// For using managed identity to access Azure resources. See https://github.com/microsoft/azure-container-apps/issues/442
@@ -1165,7 +1169,10 @@ module isolation 'network-isolation.bicep' = if (usePrivateEndpoint) {
1165
1169
tags : tags
1166
1170
vnetName : '${abbrs .virtualNetworks }${resourceToken }'
1167
1171
usePrivateEndpoint : usePrivateEndpoint
1168
- containerAppsEnvName : acaManagedEnvironmentName
1172
+ deploymentTarget : deploymentTarget
1173
+ // Need to check deploymentTarget due to https://github.com/Azure/bicep/issues/3990
1174
+ appServicePlanName : deploymentTarget == 'appservice' ? appServicePlan .outputs .name : ''
1175
+ containerAppsEnvName : deploymentTarget == 'containerapps' ? acaManagedEnvironmentName : ''
1169
1176
}
1170
1177
}
1171
1178
@@ -1227,6 +1234,51 @@ module privateEndpoints 'private-endpoints.bicep' = if (usePrivateEndpoint) {
1227
1234
}
1228
1235
}
1229
1236
1237
+ // Based on https://luke.geek.nz/azure/azure-point-to-site-vpn-and-private-dns-resolver/
1238
+ // Manual step required of updating azurevpnconfig.xml to use the correct DNS server IP address
1239
+ module dnsResolver 'br/public:avm/res/network/dns-resolver:0.5.3' = if (useVpnGateway ) {
1240
+ name : 'dnsResolverDeployment'
1241
+ scope : resourceGroup
1242
+ params : {
1243
+ name : '${abbrs .privateDnsResolver }${resourceToken }'
1244
+ location : location
1245
+ virtualNetworkResourceId : isolation .outputs .vnetId
1246
+ inboundEndpoints : [
1247
+ {
1248
+ name : 'inboundEndpoint'
1249
+ subnetResourceId : useVpnGateway ? isolation .outputs .privateDnsResolverSubnetId : ''
1250
+ }
1251
+ ]
1252
+ }
1253
+ }
1254
+
1255
+ module virtualNetworkGateway 'br/public:avm/res/network/virtual-network-gateway:0.6.1' = if (useVpnGateway ) {
1256
+ name : 'virtualNetworkGatewayDeployment'
1257
+ scope : resourceGroup
1258
+ params : {
1259
+ name : '${abbrs .networkVpnGateways }${resourceToken }'
1260
+ clusterSettings : {
1261
+ clusterMode : 'activePassiveNoBgp'
1262
+ }
1263
+ gatewayType : 'Vpn'
1264
+ virtualNetworkResourceId : isolation .outputs .vnetId
1265
+ vpnGatewayGeneration : 'Generation2'
1266
+ vpnClientAddressPoolPrefix : '172.16.201.0/24'
1267
+ skuName : 'VpnGw2'
1268
+ vpnClientAadConfiguration : {
1269
+ aadAudience : 'c632b3df-fb67-4d84-bdcf-b95ad541b5c8' // Azure VPN client
1270
+ aadIssuer : 'https://sts.windows.net/${tenant ().tenantId }/'
1271
+ aadTenant : '${environment ().authentication .loginEndpoint }${tenant ().tenantId }'
1272
+ vpnAuthenticationTypes : [
1273
+ 'AAD'
1274
+ ]
1275
+ vpnClientProtocols : [
1276
+ 'OpenVPN'
1277
+ ]
1278
+ }
1279
+ }
1280
+ }
1281
+
1230
1282
// Used to read index definitions (required when using authentication)
1231
1283
// https://learn.microsoft.com/azure/search/search-security-rbac
1232
1284
module searchReaderRoleBackend 'core/security/role.bicep' = if (useAuthentication ) {
0 commit comments