예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MsiCredentials"/> class.
 /// </summary>
 /// <param name="httpClientWrapper">The HTTP client wrapper</param>
 /// <param name="resource">The resource name - the URL for which these credentials will be used</param>
 /// <param name="tracer">The tracer</param>
 public MsiCredentials(IHttpClientWrapper httpClientWrapper, string resource, ITracer tracer)
 {
     this.resource          = resource;
     this.httpClientWrapper = httpClientWrapper;
     this.tracer            = tracer;
     this.retryPolicy       = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TelemetryDataClientBase"/> class.
        /// </summary>
        /// <param name="tracer">The tracer</param>
        /// <param name="httpClientWrapper">The HTTP client wrapper</param>
        /// <param name="credentialsFactory">The credentials factory</param>
        /// <param name="queryUri">The query URI</param>
        /// <param name="queryTimeout">The query timeout</param>
        /// <param name="telemetryDbType">The type of telemetry DB that this data client accesses</param>
        /// <param name="mainTelemetryDbId">The main telemetry DB ID - the ID of the DB on which all queries will run</param>
        /// <param name="telemetryResourceIds">the telemetry resource IDs - the IDs of the resources that store the telemetry that this data client accesses</param>
        protected TelemetryDataClientBase(
            ITracer tracer,
            IHttpClientWrapper httpClientWrapper,
            ICredentialsFactory credentialsFactory,
            Uri queryUri,
            TimeSpan queryTimeout,
            TelemetryDbType telemetryDbType,
            string mainTelemetryDbId,
            IEnumerable <string> telemetryResourceIds)
        {
            this.tracer               = Diagnostics.EnsureArgumentNotNull(() => tracer);
            this.httpClientWrapper    = Diagnostics.EnsureArgumentNotNull(() => httpClientWrapper);
            this.Timeout              = Diagnostics.EnsureArgumentInRange(() => queryTimeout, TimeSpan.FromMinutes(0), TimeSpan.FromHours(2));
            this.queryUri             = queryUri;
            this.TelemetryDbType      = telemetryDbType;
            this.MainTelemetryDbId    = Diagnostics.EnsureStringNotNullOrWhiteSpace(() => mainTelemetryDbId);
            this.TelemetryResourceIds = telemetryResourceIds?.ToList() ?? new List <string>();
            this.retryPolicy          = PolicyExtensions.CreateDefaultPolicy(this.tracer, this.TelemetryDbType.ToString());

            // Extract the host part of the URI as the credentials resource
            UriBuilder builder = new UriBuilder()
            {
                Scheme = this.queryUri.Scheme,
                Host   = this.queryUri.Host
            };

            Diagnostics.EnsureArgumentNotNull(() => credentialsFactory);
            this.credentials = credentialsFactory.Create(builder.Uri.ToString());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MetricClient"/> class
        /// </summary>
        /// <param name="tracer">The tracer</param>
        /// <param name="subscriptionId">The subscription Id</param>
        /// <param name="monitorManagementClient">Monitor management client to use to fetch metric data</param>
        public MetricClient(IExtendedTracer tracer, string subscriptionId, IMonitorManagementClient monitorManagementClient)
        {
            this.tracer = Diagnostics.EnsureArgumentNotNull(() => tracer);

            this.monitorManagementClient = monitorManagementClient;
            this.monitorManagementClient.SubscriptionId = subscriptionId;
            this.tracer      = tracer;
            this.retryPolicy = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AnalysisExecuter"/> class.
        /// </summary>
        /// <param name="httpClientWrapper">The HTTP client wrapper</param>
        /// <param name="tracer">Log wrapper</param>
        public AnalysisExecuter(IHttpClientWrapper httpClientWrapper, ITracer tracer)
        {
            this.tracer            = Diagnostics.EnsureArgumentNotNull(() => tracer);
            this.httpClientWrapper = Diagnostics.EnsureArgumentNotNull(() => httpClientWrapper);
            this.retryPolicy       = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);

            var functionAppBaseUrl = ConfigurationReader.ReadConfig("FunctionBaseUrl", true);

            this.analysisUrl = $"{functionAppBaseUrl}/api/Analyze";
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MdmClient"/> class
        /// </summary>
        /// <param name="tracer">The tracer</param>
        /// <param name="credentialsFactory">The credentials factory</param>
        /// <param name="resourceIdentifier">The resource for which we want to fetch data from MDM</param>
        /// /// <param name="monitorManagementClient">Monitor management client to use to fetch data from MDM</param>
        public MdmClient(ITracer tracer, ICredentialsFactory credentialsFactory, ResourceIdentifier resourceIdentifier, IMonitorManagementClient monitorManagementClient)
        {
            this.tracer = Diagnostics.EnsureArgumentNotNull(() => tracer);
            Diagnostics.EnsureArgumentNotNull(() => credentialsFactory);
            this.resourceIdentifier = resourceIdentifier;

            this.credentials             = credentialsFactory.Create("https://management.azure.com/");
            this.monitorManagementClient = monitorManagementClient;
            this.monitorManagementClient.SubscriptionId = resourceIdentifier.SubscriptionId;
            this.tracer      = tracer;
            this.retryPolicy = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MetricClient"/> class
        /// </summary>
        /// <param name="tracer">The tracer</param>
        /// <param name="monitorManagementClient">Monitor management client to use to fetch metric data</param>
        public MetricClient(ITracer tracer, IMonitorManagementClient monitorManagementClient)
        {
            if (tracer == null)
            {
                throw new ArgumentNullException(nameof(tracer));
            }

            if (monitorManagementClient == null)
            {
                throw new ArgumentNullException(nameof(monitorManagementClient));
            }

            this.tracer = tracer;
            this.monitorManagementClient = monitorManagementClient;
            this.retryPolicy             = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthorizationManagementClient"/> class.
 /// </summary>
 /// <param name="tracer">Log wrapper</param>
 /// <param name="httpClientWrapper">The HTTP client wrapper</param>
 public AuthorizationManagementClient(ITracer tracer, IHttpClientWrapper httpClientWrapper)
 {
     this.tracer            = Diagnostics.EnsureArgumentNotNull(() => tracer);
     this.httpClientWrapper = Diagnostics.EnsureArgumentNotNull(() => httpClientWrapper);
     this.retryPolicy       = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);
 }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureResourceManagerClient"/> class
 /// </summary>
 /// <param name="credentialsFactory">The credentials factory</param>
 /// <param name="tracer">The tracer</param>
 public AzureResourceManagerClient(ICredentialsFactory credentialsFactory, ITracer tracer)
 {
     this.credentials = credentialsFactory.Create("https://management.azure.com/");
     this.tracer      = tracer;
     this.retryPolicy = PolicyExtensions.CreateDefaultPolicy(this.tracer, DependencyName);
 }