-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConnectionService.cs
More file actions
50 lines (43 loc) · 1.39 KB
/
ConnectionService.cs
File metadata and controls
50 lines (43 loc) · 1.39 KB
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
using Microsoft.Graph.Models.ExternalConnectors;
static class ConnectionService
{
async static Task CreateConnection()
{
Console.Write("Creating connection...");
await GraphService.Client.External.Connections.PostAsync(ConnectionConfiguration.ExternalConnection);
Console.WriteLine("DONE");
}
async static Task CreateSchema()
{
Console.WriteLine("Creating schema...");
await GraphService.Client.External.Connections[ConnectionConfiguration.ExternalConnection.Id].Schema
.PatchAsync(ConnectionConfiguration.Schema);
do
{
var externalConnection = await GraphService.Client.External.Connections[ConnectionConfiguration.ExternalConnection.Id]
.GetAsync();
Console.Write($"State: {externalConnection?.State.ToString()}");
if (externalConnection?.State != ConnectionState.Draft)
{
Console.WriteLine();
break;
}
Console.WriteLine($". Waiting 60s...");
await Task.Delay(60_000);
}
while (true);
Console.WriteLine("DONE");
}
public static async Task ProvisionConnection()
{
try
{
await CreateConnection();
await CreateSchema();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}