forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions.cs
43 lines (37 loc) · 1.61 KB
/
Functions.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
// Copyright 2016-2020, Pulumi Corporation. All rights reserved.
using Pulumi;
using Pulumi.Azure.Core;
public static class Functions
{
public static Output<string> Run()
{
// Read a list of target locations from the config file:
// Expecting a comma-separated list, e.g., "westus,eastus,westeurope"
var locations = new Config().Require("locations").Split(",");
var resourceGroup = new ResourceGroup("cosmosfunctions-rg", new ResourceGroupArgs {Location = locations[0]});
var app = new CosmosApp("functions", new CosmosAppArgs
{
ResourceGroup = resourceGroup,
Locations = locations,
DatabaseName = "pricedb",
ContainerName = "prices",
Factory = global => region =>
{
var connectionString = global.CosmosAccount.ConnectionStrings.Apply(cs => cs[0]);
var func = new ArchiveFunctionApp($"afa-{region.Location}", new ArchiveFunctionAppArgs
{
ResourceGroupName = resourceGroup.Name,
Location = region.Location,
Archive = new FileArchive("./app/bin/Debug/netcoreapp3.1/publish"),
AppSettings =
{
{"CosmosDBConnection", connectionString},
},
},
new ComponentResourceOptions {Parent = global.Options.Parent});
return new AzureEndpoint(func.AppId);
},
});
return Output.Format($"{app.Endpoint}/cosmos");
}
}