-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthenticationConfig.cs
More file actions
37 lines (32 loc) · 1.24 KB
/
AuthenticationConfig.cs
File metadata and controls
37 lines (32 loc) · 1.24 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
using Microsoft.Extensions.Configuration;
using System;
using System.Globalization;
using System.IO;
namespace MyAadFunction
{
public class Config
{
/// <summary>
/// instance of Azure AD, for example public Azure or a Sovereign cloud (Azure China, Germany, US government, etc ...)
/// </summary>
public string Instance { get; set; } = "https://login.microsoftonline.com/{0}";
/// <summary>
/// Graph API endpoint, could be public Azure (default) or a Sovereign cloud (US government, etc ...)
/// </summary>
public string ApiUrl { get; set; } = "https://graph.microsoft.com/";
/// <summary>
/// Reads the configuration from a json file
/// </summary>
/// <param name="path">Path to the configuration json file</param>
/// <returns>AuthenticationConfig read from the json file</returns>
public static Config ReadFromJsonFile(string path)
{
IConfigurationRoot Configuration;
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path);
Configuration = builder.Build();
return Configuration.Get<Config>();
}
}
}