Exemplo n.º 1
0
        public IdentityClient(IdentityClientOptions options = null)
        {
            _options = options ?? new IdentityClientOptions();

            _pipeline = HttpPipeline.Build(_options,
                                           _options.ResponseClassifier,
                                           _options.RetryPolicy,
                                           ClientRequestIdPolicy.Singleton,
                                           BufferResponsePolicy.Singleton);
        }
        public SecretClient(Uri vaultUri, TokenCredential credential, SecretClientOptions options)
        {
            _vaultUri = vaultUri ?? throw new ArgumentNullException(nameof(credential));
            options   = options ?? new SecretClientOptions();

            _pipeline = HttpPipeline.Build(options,
                                           options.ResponseClassifier,
                                           options.RetryPolicy,
                                           ClientRequestIdPolicy.Singleton,
                                           new BearerTokenAuthenticationPolicy(credential, "https://vault.azure.net//.Default"),
                                           options.LoggingPolicy,
                                           BufferResponsePolicy.Singleton);
        }
        public ConfigurationClient(string connectionString, ConfigurationClientOptions options)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            ParseConnectionString(connectionString, out _baseUri, out var credential, out var secret);

            _pipeline = HttpPipeline.Build(options,
                                           options.RetryPolicy,
                                           ClientRequestIdPolicy.Singleton,
                                           new AuthenticationPolicy(credential, secret),
                                           options.LoggingPolicy);
        }
Exemplo n.º 4
0
        public async Task ComponentNameAndVersionReadFromAssembly()
        {
            string userAgent = null;

            var mockTransport = new MockTransport(
                req => {
                Assert.True(req.TryGetHeader("User-Agent", out userAgent));
                return(new MockResponse(200));
            });

            var pipeline = HttpPipeline.Build(new TestClientOptions()
            {
                Transport = mockTransport
            }, new HttpPipelinePolicy[0]);

            var request = pipeline.CreateRequest();

            request.SetRequestLine(HttpPipelineMethod.Get, new Uri("https://contoso.a.io"));
            await pipeline.SendRequestAsync(request, CancellationToken.None);

            var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Assert.AreEqual(userAgent, $"azsdk-net-base-test/{assemblyVersion} ({RuntimeInformation.FrameworkDescription}; {RuntimeInformation.OSDescription})");
        }