forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
75 lines (66 loc) · 2.18 KB
/
__main__.py
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
from pulumi import asset, export, Output
from pulumi_azure import core, storage, appservice
resource_group = core.ResourceGroup("windowsrg")
httpdotnet_storage_account = storage.Account(
"httpdotnet",
account_kind="StorageV2",
account_tier="Standard",
account_replication_type="LRS",
resource_group_name=resource_group.name,
)
httpdotnet_container=storage.Container(
"http-dotnet",
storage_account_name=httpdotnet_storage_account.name,
container_access_type="private"
)
httpdotnet_zib_blob=storage.Blob(
"http-dotnet",
storage_account_name=httpdotnet_storage_account.name,
storage_container_name=httpdotnet_container.name,
type="Block",
source=asset.AssetArchive({
".": asset.FileArchive("./dotnet/bin/Debug/netcoreapp3.1/publish")
}))
def get_sas(args):
blob_sas = storage.get_account_blob_container_sas(
connection_string=args[1],
start="2020-01-01",
expiry="2030-01-01",
container_name=args[2],
permissions={
"read": "true",
"write": "false",
"delete": "false",
"list": "false",
"add": "false",
"create": "false"
}
)
return f"https://{args[0]}.blob.core.windows.net/{args[2]}/{args[3]}{blob_sas.sas}"
httpdotnet_signed_blob_url = Output.all(
httpdotnet_storage_account.name,
httpdotnet_storage_account.primary_connection_string,
httpdotnet_container.name, httpdotnet_zib_blob.name
).apply(get_sas)
httpdotnet_plan=appservice.Plan(
"http-dotnet",
resource_group_name=resource_group.name,
kind="FunctionApp",
sku={
"tier": "Dynamic",
"size": "Y1"
}
)
httpdotnet_function_app=appservice.FunctionApp(
"http-dotnet",
resource_group_name=resource_group.name,
app_service_plan_id=httpdotnet_plan.id,
storage_connection_string=httpdotnet_storage_account.primary_connection_string,
version="~3",
app_settings={
"runtime": "dotnet",
"WEBSITE_RUN_FROM_PACKAGE": httpdotnet_signed_blob_url,
},
)
export("dotnet_endpoint", httpdotnet_function_app.default_hostname.apply(
lambda endpoint: "https://" + endpoint + "/api/HelloDotnet?name=Pulumi"))