forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions.cs
52 lines (44 loc) · 1.73 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
44
45
46
47
48
49
50
51
52
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using Pulumi;
using Pulumi.Azure.Core;
public static class Functions
{
public static IDictionary<string, object> 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/netcoreapp2.2/publish"),
AppSettings =
{
{ "CosmosDBConnection", connectionString },
},
},
global.Options);
return new AzureEndpoint(func.AppId);
},
});
return new Dictionary<string, object>
{
{ "functionsEndpoint", Output.Format($"{app.Endpoint}/cosmos") }
};
}
}