Skip to content

Commit 4943609

Browse files
committed
private dns zone
1 parent 769883c commit 4943609

File tree

6 files changed

+115
-50
lines changed

6 files changed

+115
-50
lines changed

DEPLOYMENT.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ Application will use a pre-built docker image hosted in GitHub registry: `ghcr.i
5252
https://<YOUR Container APP URL>.azurecontainerapps.io/callback
5353
```
5454
55+
### Deploying with private networking
56+
57+
When deploying to a private network, specify a subnet (at least /23) for the Azure Container Apps Environment.
58+
App deployment does not create any DNS entries for the application, in order to create a private DNS Zone linked to provided Virtual Network, follow up the deployment with DNS deployment targeting same resource group:
59+
60+
[![DNS Zone deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fkarpikpl%2Fcopilot-metrics-viewer%2Fmain%2Fazure-deploy%2Fdns%2Fazuredeploy.json)
61+
5562
## Scenario 2: Azure Deployment with azd
5663
5764
If more control over the deployed container image is needed, an infrastructure-as-code option has been provided using Azure Bicep. The application can be deployed using the [Azure Developer CLI](https://aka.ms/azd) (azd).

azure-deploy/dns/azuredeploy.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"name": {
6+
"type": "String",
7+
"defaultValue": "copilot-metrics"
8+
},
9+
"dns-zone-name": {
10+
"type": "string",
11+
"defaultValue": "xxx.eastus.azurecontainerapps.io",
12+
"metadata": {
13+
"description": "The unique DNS zone name for the managed environment in format of <random name>.<region>.azurecontainerapps.io"
14+
}
15+
}
16+
},
17+
"variables": {
18+
"environmentName": "[concat(parameters('name'),'-env')]"
19+
},
20+
"resources": [
21+
{
22+
"type": "Microsoft.Network/privateDnsZones",
23+
"apiVersion": "2020-06-01",
24+
"name": "[parameters('dns-zone-name')]",
25+
"location": "global",
26+
"properties": {}
27+
},
28+
{
29+
"type": "Microsoft.Network/privateDnsZones/A",
30+
"apiVersion": "2020-06-01",
31+
"name": "[concat(parameters('dns-zone-name'), '/*')]",
32+
"properties": {
33+
"ttl": 3600,
34+
"aRecords": [
35+
{
36+
"ipv4Address": "[reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').staticIp]"
37+
}
38+
]
39+
},
40+
"dependsOn": [
41+
"[resourceId('Microsoft.Network/privateDnsZones', parameters('dns-zone-name'))]"
42+
]
43+
},
44+
{
45+
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
46+
"apiVersion": "2020-06-01",
47+
"name": "[concat( parameters('dns-zone-name'), '/', variables('environmentName'), '-vnet-link')]",
48+
"location": "global",
49+
"dependsOn": [
50+
"[resourceId('Microsoft.Network/privateDnsZones', parameters('dns-zone-name'))]"
51+
],
52+
"properties": {
53+
"virtualNetwork": {
54+
"id": "[split(reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').vnetConfiguration.infrastructureSubnetId, '/subnets/')[0]]"
55+
},
56+
"registrationEnabled": false
57+
}
58+
}
59+
],
60+
"outputs": {
61+
"managed-environment-ip": {
62+
"type": "string",
63+
"value": "[reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').staticIp]"
64+
},
65+
"managed-environment-domain": {
66+
"type": "string",
67+
"value": "[reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').defaultDomain]"
68+
}
69+
}
70+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {}
5+
}

azure-deploy/dns/metadata.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#",
3+
"itemDisplayName": "Create DNS Zones for Azure Container App",
4+
"description": "This template creates a private DNS Zone for Azure Container App showing GitHub copilot metrics",
5+
"summary": "Create Azure Container App showing GitHub copilot metrics",
6+
"githubUsername": "karpikpl",
7+
"docOwner": "karpikpl",
8+
"dateUpdated": "2024-08-02",
9+
"type": "Application",
10+
"tags": {
11+
"subscriptiontype": "Azure4Student",
12+
"resource": "Private DNS Zone",
13+
"level": "Beginner",
14+
"cost": "$"
15+
}
16+
}

azure-deploy/with-app-registration/azuredeploy.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
}
150150
},
151151
"vnetConfiguration": {
152-
"infrastructureSubnetId" : "[parameters('subnetId')]",
152+
"infrastructureSubnetId": "[parameters('subnetId')]",
153153
"internal": "[if(equals(parameters('subnetId'), ''), json('false'), json('true'))]"
154154
}
155155
}
@@ -168,5 +168,19 @@
168168
"workspaceCapping": {}
169169
}
170170
}
171-
]
171+
],
172+
"outputs": {
173+
"metrics-viewer-url": {
174+
"type": "string",
175+
"value": "[reference(concat('Microsoft.App/containerapps/', parameters('name')), '2024-02-02-preview').latestRevisionFqdn]"
176+
},
177+
"managed-environment-ip": {
178+
"type": "string",
179+
"value": "[reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').staticIp]"
180+
},
181+
"managed-environment-domain": {
182+
"type": "string",
183+
"value": "[reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').defaultDomain]"
184+
}
185+
}
172186
}

azure-deploy/with-token/azuredeploy.json

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151
"variables": {
5252
"environmentName": "[concat(parameters('name'),'-env')]",
5353
"workspaceName": "[concat(parameters('name'),'-ai')]",
54-
"app-scope": "[if(not(empty(parameters('github-organization'))), 'organization', if(not(empty(parameters('github-enterprise'))), 'enterprise', ''))]",
55-
"vnetId": "[concat(split(parameters('subnetId'), '/subnets/')[0])]",
56-
"dnsZoneName": "azurecontainerapps.io"
54+
"app-scope": "[if(not(empty(parameters('github-organization'))), 'organization', if(not(empty(parameters('github-enterprise'))), 'enterprise', ''))]"
5755
},
5856
"resources": [
5957
{
@@ -146,51 +144,6 @@
146144
}
147145
}
148146
},
149-
{
150-
"type": "Microsoft.Network/privateDnsZones",
151-
"apiVersion": "2020-06-01",
152-
"name": "[variables('dnsZoneName')]",
153-
"location": "global",
154-
"condition": "[not(equals(parameters('subnetId'), ''))]",
155-
"properties": {},
156-
"dependsOn": [
157-
"[concat('Microsoft.App/managedEnvironments/', variables('environmentName'))]"
158-
]
159-
},
160-
{
161-
"type": "Microsoft.Network/privateDnsZones/A",
162-
"apiVersion": "2020-06-01",
163-
"name": "[concat(variables('dnsZoneName'), '/*')]",
164-
"properties": {
165-
"TTL": 3600,
166-
"ARecords": [
167-
{
168-
"ipv4Address": "[reference(concat('Microsoft.App/managedEnvironments/', variables('environmentName')), '2024-02-02-preview').staticIp]"
169-
170-
}
171-
]
172-
},
173-
"dependsOn": [
174-
"[resourceId('Microsoft.Network/privateDnsZones', variables('dnsZoneName'))]",
175-
"[concat('Microsoft.App/managedEnvironments/', variables('environmentName'))]"
176-
]
177-
},
178-
{
179-
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
180-
"apiVersion": "2020-06-01",
181-
"name": "[concat(variables('dnsZoneName'), '/', variables('environmentName'), '-vnet-link')]",
182-
"location": "global",
183-
"dependsOn": [
184-
"[resourceId('Microsoft.Network/privateDnsZones', variables('dnsZoneName'))]"
185-
],
186-
"condition": "[not(equals(parameters('subnetId'), ''))]",
187-
"properties": {
188-
"virtualNetwork": {
189-
"id": "[variables('vnetId')]"
190-
},
191-
"registrationEnabled": false
192-
}
193-
},
194147
{
195148
"apiVersion": "2020-08-01",
196149
"name": "[variables('workspaceName')]",

0 commit comments

Comments
 (0)