microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Bot.Core/Hosting/BotConfig.cs
40lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Extensions.Configuration; |
| 5 | |
| 6 | namespace Microsoft.Bot.Core.Hosting; |
| 7 | |
| 8 | |
| 9 | internal sealed class BotConfig |
| 10 | { |
| 11 | public const string SystemManagedIdentityIdentifier = "system"; |
| 12 | |
| 13 | public string TenantId { get; set; } = string.Empty; |
| 14 | public string ClientId { get; set; } = string.Empty; |
| 15 | public string? ClientSecret { get; set; } |
| 16 | public string? FicClientId { get; set; } |
| 17 | |
| 18 | public static BotConfig FromBFConfig(IConfiguration configuration) |
| 19 | { |
| 20 | ArgumentNullException.ThrowIfNull(configuration); |
| 21 | return new() |
| 22 | { |
| 23 | TenantId = configuration["MicrosoftAppTenantId"] ?? string.Empty, |
| 24 | ClientId = configuration["MicrosoftAppId"] ?? string.Empty, |
| 25 | ClientSecret = configuration["MicrosoftAppPassword"], |
| 26 | }; |
| 27 | } |
| 28 | |
| 29 | public static BotConfig FromCoreConfig(IConfiguration configuration) |
| 30 | { |
| 31 | ArgumentNullException.ThrowIfNull(configuration); |
| 32 | return new() |
| 33 | { |
| 34 | TenantId = configuration["TENANT_ID"] ?? string.Empty, |
| 35 | ClientId = configuration["CLIENT_ID"] ?? string.Empty, |
| 36 | ClientSecret = configuration["CLIENT_SECRET"], |
| 37 | FicClientId = configuration["MANAGED_IDENTITY_CLIENT_ID"], |
| 38 | }; |
| 39 | } |
| 40 | } |
| 41 | |