public async Task <HttpResponseMessage> GetAccountInfo(string tenantName) { var client = ReadOnlyTenantCacheClient.GetClient(true); var tenant = await client.GetTenantAsync(tenantName); Validator.IsTrue <ArgumentException>(tenant != null, nameof(tenant), "Tenant '{0}' does not exist.", tenantName); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(tenant), Encoding.UTF8, "application/json") }); }
private async Task <Account> InitAccount(string account) { // Get subscriptionId from TenantCache var client = ReadOnlyTenantCacheClient.GetClient(false); var tenant = await client.GetTenantAsync(account); Validator.IsTrue <ArgumentException>(tenant != null, nameof(tenant), "Account '{0}' does not exist.", account); return(await this.CreateOrUpdateAccountAsync(new Account(account) { SubscriptionId = tenant.SubscriptionId })); }
public static async Task <string> GetSubscriptionId(string account) { try { if (string.IsNullOrEmpty(account)) { return(string.Empty); } var client = ReadOnlyTenantCacheClient.GetClient(true); var tenant = await client.GetTenantAsync(account); return(tenant?.SubscriptionId ?? string.Empty); } catch { return(string.Empty); } }
private async Task <Account> ValidateAccount(string account) { var currentAccount = await this.store.GetAccountAsync(account); if (currentAccount == null) { SmsProviderEventSource.Current.Critical(SmsProviderEventSource.EmptyTrackingId, this, nameof(this.ValidateAccount), OperationStates.Empty, $"Account {account} is never initialized. Try to re-init here"); // Get subscriptionId var client = ReadOnlyTenantCacheClient.GetClient(false); var tenant = await client.GetTenantAsync(account); currentAccount = await this.CreateOrUpdateAccountAsync(new Account(account) { SubscriptionId = tenant.SubscriptionId }); } Validator.IsTrue <ArgumentException>(currentAccount != null, nameof(currentAccount), "Account '{0}' does not exist.", account); return(currentAccount); }