Exemplo n.º 1
0
        public async Task <TenantsList> GetTenantsList()
        {
            var authResult = await _authContext.AcquireTokenSilentAsync("https://management.core.windows.net/", _clientCredential, new UserIdentifier(_userObjectId, UserIdentifierType.UniqueId));

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);

                var    response        = httpClient.PostAsync("https://portal.azure.com/AzureHubs/api/tenants/List", null).Result;
                string responseContent = await response.Content.ReadAsStringAsync();

                if (!response.IsSuccessStatusCode)
                {
                    return(null);
                }
                else
                {
                    TenantsList tenants = JsonConvert.DeserializeObject <TenantsList>(responseContent);
                    return(tenants);
                }
            }
        }
Exemplo n.º 2
0
 public TenantForm()
 {
     TenantsList = new TenantsList();
 }