-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deployment.fsx
73 lines (55 loc) · 2 KB
/
Deployment.fsx
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
#r "nuget:Farmer"
open Farmer
open Farmer.Builders
open System
/// Creates a PgSql and web app resources for a specific environment e.g. "dev" or "test".
let createEnvironment envName =
let appName = "myApp"
let dbServerName = $"%s{appName}-dbserver-{envName}"
// Currently deploys a single-instance PostgreSQL server
// Farmer is being updated to support Flexible databases.
let pgServer =
let database = postgreSQLDb { name appName }
postgreSQL {
name dbServerName
add_database database
capacity 1<VCores>
admin_username "dbsuperuser"
}
let logStore = logAnalytics { name $"{appName}-logstore-{envName}" }
let insights =
appInsights {
name $"{appName}-insights-{envName}"
log_analytics_workspace logStore
}
let app =
webApp {
name $"{appName}-web-{envName}"
setting "DbDomainName" pgServer.FullyQualifiedDomainName
secret_setting "DbPassword"
operating_system Linux
runtime_stack Runtime.DotNet80
run_from_package
zip_deploy "src/App/bin/release/net8.0/publish"
sku WebApp.Sku.B1
always_on
link_to_app_insights insights
// uncomment next line once Farmer 1.8.13 is released.
//depends_on pgServer
}
let rg =
resourceGroup {
location Location.WestEurope
add_resources [ pgServer; app; insights; logStore ]
add_tags [ "environment", envName ]
}
rg, dbServerName
let envName = "test"
let deployment, dbServerName = createEnvironment envName
deployment |> Writer.quickWrite "template"
let dbPassword =
match Environment.GetEnvironmentVariable "DbPassword" with
| null -> failwith "DbPassword environment variable not set"
| value -> value
deployment
|> Deploy.execute $"impactDemo-{envName}" [ $"password-for-{dbServerName}", dbPassword; "DbPassword", dbPassword ]