Skip to content

Commit ce59123

Browse files
author
Vivek Lakshmanan
committed
More documentation
1 parent bcc804b commit ce59123

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
1+
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)
2+
13
# Deploy two App Services - Front web app with VNet injection and Back web app with a Private Endpoint
24

35
**Note** This is a port of https://github.com/Azure/azure-quickstart-templates/tree/master/101-webapp-privateendpoint-vnet-injection to Pulumi's Azure-Nextgen SDK.
46

7+
58
This deploys a secure front end - back end web app. The front end web app (`site2`) is plugged in a subnet with the feature regional VNet integration enabled. Settings are set to consume a DNS private zone. The backend web app (`site1`) is only exposed through a private endpoint.
69

710
It will create a VNet, two subnets, one where your Private Endpoint will exist, the second where you will inject the front web app, an App Service Plan in PremiumV2 tier (mandatory for Private Endpoint), a Private Endpoint, settings for DNS queries to the DNS Private Zone, and a private DNS zone with record for the Private Endpoint.
811

9-
## Required config params
12+
### Prerequisites
13+
14+
1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/)
15+
2. [Install node.js](https://nodejs.org/en/download/)
16+
3. [Configure Azure Credentials](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/)
17+
18+
19+
### Required config params
1020
`resourceGroupNameParam` - name for the resource group.
21+
22+
### Steps
23+
24+
After cloning this repo, from this working directory, run these commands:
25+
26+
1. Create a new stack, which is an isolated deployment target for this example:
27+
28+
```bash
29+
$ pulumi stack init dev
30+
```
31+
32+
1. Next, install the dependencies:
33+
34+
```bash
35+
$ npm install
36+
```
37+
38+
1. Stand up the cluster by invoking pulumi
39+
```bash
40+
$ pulumi up
41+
```

azure-nextgen-ts-webapp-privateendpoint-vnet-injection/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
2+
13
import * as azure_nextgen from "@pulumi/azure-nextgen";
24
import * as pulumi from "@pulumi/pulumi";
35
import * as random from "@pulumi/random";
@@ -31,10 +33,13 @@ const serverfarm = new azure_nextgen.web.v20190801.AppServicePlan("serverfarm",
3133
},
3234
});
3335

36+
// To get a random suffix
3437
const rand = new random.RandomString("random", {
3538
length: 5,
3639
special: false,
3740
});
41+
42+
// Setup backend app
3843
const site1NameParam = config.get("site1NameParam") || pulumi.interpolate `webapp1${rand.result}`;
3944
const site1 = new azure_nextgen.web.v20190801.WebApp("backendApp", {
4045
kind: "app",
@@ -56,6 +61,7 @@ new azure_nextgen.web.v20190801.WebAppHostNameBinding("hostNameBindingSite1", {
5661
siteName: site1.name,
5762
});
5863

64+
// Setup frontend app
5965
const site2NameParam = config.get("site2NameParam") || pulumi.interpolate `webapp2${rand.result}`;
6066
const site2 = new azure_nextgen.web.v20190801.WebApp("frontendApp", {
6167
kind: "app",
@@ -80,6 +86,8 @@ new azure_nextgen.web.v20190801.WebAppHostNameBinding("hostNameBindingSite2", {
8086
const virtualNetworkNameParam = config.get("virtualNetworkNameParam") || "vnet";
8187
const privateDNSZoneName = "privatelink.azurewebsites.net";
8288
const virtualNetworkCIDRParam = config.get("virtualNetworkCIDRParam") || "10.200.0.0/16";
89+
90+
// Setup a vnet
8391
const virtualNetwork = new azure_nextgen.network.v20200401.VirtualNetwork("virtualNetwork", {
8492
addressSpace: {
8593
addressPrefixes: [virtualNetworkCIDRParam],
@@ -88,6 +96,7 @@ const virtualNetwork = new azure_nextgen.network.v20200401.VirtualNetwork("virtu
8896
resourceGroupName: resourceGroup.name,
8997
virtualNetworkName: virtualNetworkNameParam,
9098
});
99+
// Setup private DNS zone
91100
const privateDnsZone = new azure_nextgen.network.v20180901.PrivateZone("privateDnsZone", {
92101
location: "global",
93102
privateZoneName: privateDNSZoneName,
@@ -99,13 +108,16 @@ const privateEndpointNameParam = config.get("privateEndpointNameParam") || "Priv
99108
const privateLinkConnectionNameParam = config.get("privateLinkConnectionNameParam") || "PrivateEndpointLink1";
100109
const subnet1NameParam = config.get("subnet1NameParam") || "SubnetForSite1";
101110
const subnet1CIDRParam = config.get("subnet1CIDRParam") || "10.200.1.0/24";
111+
// Setup a private subnet
102112
const subnet1 = new azure_nextgen.network.v20200401.Subnet("subnet1", {
103113
addressPrefix: subnet1CIDRParam,
104114
privateEndpointNetworkPolicies: "Disabled",
105115
resourceGroupName: resourceGroup.name,
106116
subnetName: subnet1NameParam,
107117
virtualNetworkName: virtualNetwork.name,
108118
});
119+
120+
// Private endpoint in the private subnet for site1 (backend)
109121
const privateEndpoint = new azure_nextgen.network.v20200501.PrivateEndpoint("privateEndpoint", {
110122
location: locationParam,
111123
privateEndpointName: privateEndpointNameParam,
@@ -119,6 +131,8 @@ const privateEndpoint = new azure_nextgen.network.v20200501.PrivateEndpoint("pri
119131
id: subnet1.id,
120132
},
121133
});
134+
135+
// Setup a private DNS Zone for private endpoint
122136
new azure_nextgen.network.v20200301.PrivateDnsZoneGroup("privateDnsZoneGroup", {
123137
privateDnsZoneConfigs: [{
124138
name: "config1",
@@ -139,6 +153,7 @@ new azure_nextgen.network.v20180901.VirtualNetworkLink("virtualNetworkLink", {
139153
virtualNetworkLinkName: pulumi.interpolate `${privateDNSZoneName}-link`,
140154
});
141155

156+
// Now setup subnet for site2 (frontend)
142157
const subnet2NameParam = config.get("subnet2NameParam") || "SubnetForSite2";
143158
const subnet2CIDRParam = config.get("subnet2CIDRParam") || "10.200.2.0/24";
144159
const subnet2 = new azure_nextgen.network.v20200401.Subnet("subnet2", {

0 commit comments

Comments
 (0)