Exemplo n.º 1
0
        private async Task <EventHubManagementClient> GetClientAsync(GeoDRConfig config)
        {
            var token = await GetAuthorizationHeaderAsync(config);

            var creds  = new TokenCredentials(token);
            var client = new EventHubManagementClient(creds)
            {
                SubscriptionId = config.SubscriptionId
            };

            return(client);
        }
Exemplo n.º 2
0
        private async Task <string> GetAuthorizationHeaderAsync(GeoDRConfig config)
        {
            var context = new AuthenticationContext($"{config.ActiveDirectoryAuthority}/{config.TenantId}");

            AuthenticationResult result = await context.AcquireTokenAsync(
                config.ResourceManagerUrl,
                new ClientCredential(config.ClientId, config.ClientSecrets));

            if (result == null)
            {
                throw new InvalidOperationException("Failed to obtain token for authentication");
            }

            string token = result.AccessToken;

            return(token);
        }