forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
86 lines (72 loc) · 2.59 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as azure from "@pulumi/azure";
import * as docker from "@pulumi/docker";
import * as pulumi from "@pulumi/pulumi";
// Create an Azure Resource Group
const resourceGroup = new azure.core.ResourceGroup("samples");
// Create a dedicated App Service Plan for Linux App Services
const plan = new azure.appservice.Plan("linux-apps", {
resourceGroupName: resourceGroup.name,
kind: "Linux",
reserved: true,
sku: {
tier: "Basic",
size: "B1",
},
});
/**
* Scenario 1: deploying an image from Docker Hub.
* The example uses a HelloWorld application written in Go.
* Image: https://hub.docker.com/r/microsoft/azure-appservices-go-quickstart/
*/
const imageInDockerHub = "microsoft/azure-appservices-go-quickstart";
const helloApp = new azure.appservice.AppService("hello-app", {
resourceGroupName: resourceGroup.name,
appServicePlanId: plan.id,
appSettings: {
WEBSITES_ENABLE_APP_SERVICE_STORAGE: "false",
},
siteConfig: {
alwaysOn: true,
linuxFxVersion: `DOCKER|${imageInDockerHub}`,
},
httpsOnly: true,
});
export const helloEndpoint = pulumi.interpolate`https://${helloApp.defaultSiteHostname}/hello`;
/**
* Scenario 2: deploying a custom image from Azure Container Registry.
*/
const customImage = "node-app";
const registry = new azure.containerservice.Registry("myregistry", {
resourceGroupName: resourceGroup.name,
sku: "Basic",
adminEnabled: true,
});
const myImage = new docker.Image(customImage, {
imageName: pulumi.interpolate`${registry.loginServer}/${customImage}:v1.0.0`,
build: {
context: `./${customImage}`,
},
registry: {
server: registry.loginServer,
username: registry.adminUsername,
password: registry.adminPassword,
},
});
const getStartedApp = new azure.appservice.AppService("get-started", {
resourceGroupName: resourceGroup.name,
appServicePlanId: plan.id,
appSettings: {
WEBSITES_ENABLE_APP_SERVICE_STORAGE: "false",
DOCKER_REGISTRY_SERVER_URL: pulumi.interpolate`https://${registry.loginServer}`,
DOCKER_REGISTRY_SERVER_USERNAME: registry.adminUsername,
DOCKER_REGISTRY_SERVER_PASSWORD: registry.adminPassword,
WEBSITES_PORT: "80", // Our custom image exposes port 80. Adjust for your app as needed.
},
siteConfig: {
alwaysOn: true,
linuxFxVersion: pulumi.interpolate`DOCKER|${myImage.imageName}`,
},
httpsOnly: true,
});
export const getStartedEndpoint = pulumi.interpolate`https://${getStartedApp.defaultSiteHostname}`;