Skip to content

Commit ced5983

Browse files
committed
Private endpoint almost working
1 parent b754767 commit ced5983

13 files changed

+330
-262
lines changed

app/backend/prepdocs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ async def main(strategy: Strategy, setup_index: bool = True):
323323

324324
load_azd_env()
325325

326-
if os.getenv("AZURE_PUBLIC_NETWORK_ACCESS") == "Disabled":
326+
if os.getenv("AZURE_PUBLIC_NETWORK_ACCESS") == "Disabled" and os.getenv("AZURE_USE_VPN_GATEWAY") != "true":
327327
logger.error("AZURE_PUBLIC_NETWORK_ACCESS is set to Disabled. Exiting.")
328328
exit(0)
329329

docs/deploy_private.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,51 @@ Deploying with public access disabled adds additional cost to your deployment. P
4646

4747
## Recommended deployment strategy for private access
4848

49-
1. Deploy the app with private endpoints enabled and public access enabled.
49+
1. Deploy the app with private endpoints enabled, public network access disabled, and a VPN gateway configured. This will allow you to connect to the chat app from inside the virtual network.
5050

51-
```shell
52-
azd env set AZURE_USE_PRIVATE_ENDPOINT true
53-
azd env set AZURE_PUBLIC_NETWORK_ACCESS Enabled
54-
azd up
55-
```
51+
```shell
52+
azd env set AZURE_USE_PRIVATE_ENDPOINT true
53+
azd env set AZURE_USE_VPN_GATEWAY true
54+
azd env set AZURE_PUBLIC_NETWORK_ACCESS Enabled
55+
azd up
56+
```
5657

57-
1. Validate that you can connect to the chat app and it's working as expected from the internet.
58-
1. Re-provision the app with public access disabled.
58+
2. First provision all the resources:
5959

60-
```shell
61-
azd env set AZURE_PUBLIC_NETWORK_ACCESS Disabled
62-
azd provision
63-
```
60+
```bash
61+
azd provision
62+
```
6463

65-
1. Log into your network using a tool like [Azure VPN Gateway](https://azure.microsoft.com/services/vpn-gateway/) and validate that you can connect to the chat app from inside the network.
64+
3. Once provisioning is complete, run this command to get the VPN configuration download link:
65+
66+
```bash
67+
azd env get-value AZURE_VPN_CONFIG_DOWNLOAD_LINK
68+
```
69+
70+
Select "Download VPN client" to download a ZIP file containing the VPN configuration.
71+
72+
4. Open `AzureVPN/azurevpnconfig.xml`, and replace the `<clientconfig>` empty tag with the following:
73+
74+
```xml
75+
<clientconfig>
76+
<dnsservers>
77+
<dnsserver>10.0.11.4</dnsserver>
78+
</dnsservers>
79+
</clientconfig>
80+
```
81+
82+
5. Open the "Azure VPN" client and select "Import" button. Select the `azurevpnconfig.xml` file you just downloaded and modified.
83+
84+
6. Select "Connect" and the new VPN connection. You will be prompted to select your Microsoft account and login.
85+
86+
7. Once you're successfully connected to VPN, you can run the data ingestion script:
87+
88+
```bash
89+
azd hooks run postprovision
90+
```
91+
92+
8. Finally, you can deploy the app:
93+
94+
```bash
95+
azd deploy
96+
```
Lines changed: 35 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,57 @@
1-
metadata description = 'Creates or updates an existing Azure Container App.'
21
param name string
32
param location string = resourceGroup().location
43
param tags object = {}
54

6-
7-
@description('The number of CPU cores allocated to a single container instance, e.g., 0.5')
8-
param containerCpuCoreCount string = '0.5'
9-
10-
@description('The maximum number of replicas to run. Must be at least 1.')
11-
@minValue(1)
12-
param containerMaxReplicas int = 10
13-
14-
@description('The amount of memory allocated to a single container instance, e.g., 1Gi')
15-
param containerMemory string = '1.0Gi'
16-
17-
@description('The minimum number of replicas to run. Must be at least 1 for non-consumption workloads.')
18-
param containerMinReplicas int = 0
19-
20-
@description('The name of the container')
5+
param containerAppsEnvironmentName string
216
param containerName string = 'main'
22-
23-
@description('The environment name for the container apps')
24-
param containerAppsEnvironmentName string = '${containerName}env'
25-
26-
@description('The name of the container registry')
277
param containerRegistryName string
288

29-
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
30-
param containerRegistryHostSuffix string = 'azurecr.io'
31-
32-
@allowed(['http', 'grpc'])
33-
@description('The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC')
34-
param daprAppProtocol string = 'http'
35-
36-
@description('Enable or disable Dapr for the container app')
37-
param daprEnabled bool = false
38-
39-
@description('The Dapr app ID')
40-
param daprAppId string = containerName
41-
42-
@description('Specifies if the resource already exists')
43-
param exists bool = false
44-
45-
@description('Specifies if Ingress is enabled for the container app')
46-
param ingressEnabled bool = true
47-
48-
@description('The type of identity for the resource')
49-
@allowed(['None', 'SystemAssigned', 'UserAssigned'])
50-
param identityType string = 'None'
51-
52-
@description('The name of the user-assigned identity')
53-
param identityName string = ''
54-
55-
@description('The name of the container image')
56-
param imageName string = ''
9+
@description('Minimum number of replicas to run')
10+
@minValue(1)
11+
param containerMinReplicas int = 1
12+
@description('Maximum number of replicas to run')
13+
@minValue(1)
14+
param containerMaxReplicas int = 10
5715

5816
@description('The secrets required for the container')
5917
@secure()
6018
param secrets object = {}
6119

62-
@description('The keyvault identities required for the container')
63-
@secure()
64-
param keyvaultIdentities object = {}
65-
6620
@description('The environment variables for the container in key value pairs')
6721
param env object = {}
6822

6923
@description('The environment variables with secret references')
7024
param envSecrets array = []
7125

72-
@description('Specifies if the resource ingress is exposed externally')
7326
param external bool = true
27+
param targetPort int = 80
28+
param exists bool
7429

75-
@description('The service binds associated with the container')
76-
param serviceBinds array = []
30+
@description('User assigned identity name')
31+
param identityName string
7732

78-
@description('The target port for the container')
79-
param targetPort int = 80
33+
@description('Enabled Ingress for container app')
34+
param ingressEnabled bool = true
35+
36+
// Dapr Options
37+
@description('Enable Dapr')
38+
param daprEnabled bool = false
39+
@description('Dapr app ID')
40+
param daprAppId string = containerName
41+
@allowed([ 'http', 'grpc' ])
42+
@description('Protocol used by Dapr to connect to the app, e.g. http or grpc')
43+
param daprAppProtocol string = 'http'
8044

81-
@allowed(['Consumption', 'D4', 'D8', 'D16', 'D32', 'E4', 'E8', 'E16', 'E32', 'NC24-A100', 'NC48-A100', 'NC96-A100'])
82-
param workloadProfile string = 'Consumption'
45+
@description('CPU cores allocated to a single container instance, e.g. 0.5')
46+
param containerCpuCoreCount string = '0.5'
47+
48+
@description('Memory allocated to a single container instance, e.g. 1Gi')
49+
param containerMemory string = '1.0Gi'
8350

84-
param allowedOrigins array = []
51+
@description('Workload profile name to use for the container app when using private ingress')
52+
param workloadProfileName string = 'Warm'
8553

86-
resource existingApp 'Microsoft.App/containerApps@2023-05-02-preview' existing = if (exists) {
54+
resource existingApp 'Microsoft.App/containerApps@2022-03-01' existing = if (exists) {
8755
name: name
8856
}
8957

@@ -98,16 +66,13 @@ module app 'container-app.bicep' = {
9866
name: '${deployment().name}-update'
9967
params: {
10068
name: name
101-
workloadProfile: workloadProfile
10269
location: location
10370
tags: tags
104-
identityType: identityType
10571
identityName: identityName
10672
ingressEnabled: ingressEnabled
10773
containerName: containerName
10874
containerAppsEnvironmentName: containerAppsEnvironmentName
10975
containerRegistryName: containerRegistryName
110-
containerRegistryHostSuffix: containerRegistryHostSuffix
11176
containerCpuCoreCount: containerCpuCoreCount
11277
containerMemory: containerMemory
11378
containerMinReplicas: containerMinReplicas
@@ -116,20 +81,19 @@ module app 'container-app.bicep' = {
11681
daprAppId: daprAppId
11782
daprAppProtocol: daprAppProtocol
11883
secrets: secrets
119-
keyvaultIdentities: keyvaultIdentities
120-
allowedOrigins: allowedOrigins
12184
external: external
12285
env: concat(envAsArray, envSecrets)
123-
imageName: !empty(imageName) ? imageName : exists ? existingApp.properties.template.containers[0].image : ''
86+
imageName: exists ? existingApp.properties.template.containers[0].image : ''
12487
targetPort: targetPort
125-
serviceBinds: serviceBinds
88+
// Pass workload profile name parameter
89+
workloadProfileName: workloadProfileName
12690
}
12791
}
12892

12993
output defaultDomain string = app.outputs.defaultDomain
13094
output imageName string = app.outputs.imageName
13195
output name string = app.outputs.name
96+
output hostName string = app.outputs.hostName
13297
output uri string = app.outputs.uri
133-
output id string = app.outputs.id
134-
output identityPrincipalId string = app.outputs.identityPrincipalId
13598
output identityResourceId string = app.outputs.identityResourceId
99+
output identityPrincipalId string = app.outputs.identityPrincipalId

0 commit comments

Comments
 (0)