forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.fs
89 lines (75 loc) · 2.97 KB
/
Program.fs
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
87
88
89
module Program
open Pulumi
open Pulumi.FSharp
open Pulumi.Azure.AppService
open Pulumi.Azure.AppService.Inputs
open Pulumi.Azure.Core
open Pulumi.Azure.Sql
open Pulumi.Azure.Storage
let infra () =
let resourceGroup = ResourceGroup "appservice-rg"
let storageAccount =
Account("sa",
AccountArgs
(ResourceGroupName = io resourceGroup.Name,
AccountReplicationType = input "LRS",
AccountTier = input "Standard"))
let sku = PlanSkuArgs(Tier = input "Basic", Size = input "B1")
let appServicePlan =
Plan("asp",
PlanArgs
(ResourceGroupName = io resourceGroup.Name,
Kind = input "App",
Sku = input sku))
let container =
Container("zips",
ContainerArgs
(StorageAccountName = io storageAccount.Name,
ContainerAccessType = input "private"))
let archive = FileArchive("wwwroot") :> AssetOrArchive
let blob =
Blob("zip",
BlobArgs
(StorageAccountName = io storageAccount.Name,
StorageContainerName = io container.Name,
Type = input "Block",
Source = input archive))
let codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount)
let config = Config()
let username = config.Get "sqlAdmin"
let password = config.RequireSecret "sqlPassword"
let sqlServer =
SqlServer("sql",
SqlServerArgs
(ResourceGroupName = io resourceGroup.Name,
AdministratorLogin = input (if not(isNull username) then username else "pulumi"),
AdministratorLoginPassword = io password,
Version = input "12.0"))
let database =
Database("db",
DatabaseArgs
(ResourceGroupName = io resourceGroup.Name,
ServerName = io sqlServer.Name,
RequestedServiceObjectiveName = input "S0"))
let connectionString =
Outputs.pair3 sqlServer.Name database.Name password
|> Outputs.apply(fun (server, database, pwd) ->
sprintf
"Server= tcp:%s.database.windows.net;initial catalog=%s;userID=%s;password=%s;Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;"
server database username pwd)
let connectionStringSetting =
AppServiceConnectionStringsArgs
(Name = input "db",
Type = input "SQLAzure",
Value = io connectionString)
let app =
AppService("app",
AppServiceArgs
(ResourceGroupName = io resourceGroup.Name,
AppServicePlanId = io appServicePlan.Id,
AppSettings = inputMap ["WEBSITE_RUN_FROM_PACKAGE", io codeBlobUrl],
ConnectionStrings = inputList [input connectionStringSetting]))
dict [("endpoint", app.DefaultSiteHostname :> obj)]
[<EntryPoint>]
let main _ =
Deployment.run infra