forked from jetvova/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArchiveFunctionApp.cs
84 lines (70 loc) · 2.72 KB
/
ArchiveFunctionApp.cs
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
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
using System.Collections.Generic;
using Pulumi;
using Pulumi.Azure.AppService;
using Pulumi.Azure.AppService.Inputs;
using Pulumi.Azure.Storage;
public class ArchiveFunctionApp : ComponentResource
{
public Output<string> AppId { get; private set; } = null!;
public ArchiveFunctionApp(string name, ArchiveFunctionAppArgs args, ComponentResourceOptions? options = null)
: base("examples:azure:ArchiveFunctionApp", name, options)
{
var opts = new CustomResourceOptions { Parent = this };
var storageAccount = new Account($"sa{args.Location}", new AccountArgs
{
ResourceGroupName = args.ResourceGroupName,
Location = args.Location,
AccountReplicationType = "LRS",
AccountTier = "Standard",
}, opts);
var appServicePlan = new Plan($"asp-{args.Location}", new PlanArgs
{
ResourceGroupName = args.ResourceGroupName,
Location = args.Location,
Kind = "FunctionApp",
Sku = new PlanSkuArgs
{
Tier = "Dynamic",
Size = "Y1",
},
}, opts);
var container = new Container($"zips-{args.Location}", new ContainerArgs
{
StorageAccountName = storageAccount.Name,
ContainerAccessType = "private",
}, opts);
var blob = new Blob($"zip-{args.Location}", new BlobArgs
{
StorageAccountName = storageAccount.Name,
StorageContainerName = container.Name,
Type = "Block",
Source = args.Archive,
}, opts);
var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);
args.AppSettings.Add("runtime", "dotnet");
args.AppSettings.Add("WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl);
var app = new FunctionApp($"app-{args.Location}", new FunctionAppArgs
{
ResourceGroupName = args.ResourceGroupName,
Location = args.Location,
AppServicePlanId = appServicePlan.Id,
AppSettings = args.AppSettings,
StorageConnectionString = storageAccount.PrimaryConnectionString,
Version = "~2",
}, opts);
this.AppId = app.Id;
}
}
public class ArchiveFunctionAppArgs
{
public Input<string> ResourceGroupName { get; set; } = null!;
public string Location { get; set; } = null!;
public Input<AssetOrArchive> Archive { get; set; } = null!;
private InputMap<string>? _appSettings;
public InputMap<string> AppSettings
{
get => _appSettings ?? (_appSettings = new InputMap<string>());
set => _appSettings = value;
}
}