private List <Instance> GetInstances(Uri endpointUri, int instanceCount, RegionInformation regionInformation)
        {
            var instancePortMinimum = _configuration.Value.InstancePortMinimum;

            _logger.LogInformation(
                "Testing {InstanceCount} instances, starting at port {InstancePortMinimum} for region {Region}.",
                instanceCount,
                instancePortMinimum,
                regionInformation.Region);

            return(Enumerable
                   .Range(0, instanceCount)
                   .Select(i =>
            {
                var diagUriBuilder = new UriBuilder(endpointUri);

                diagUriBuilder.Scheme = "https";
                diagUriBuilder.Port = instancePortMinimum + i;
                diagUriBuilder.Path = "search/diag";

                var queryBaseUriBuilder = new UriBuilder(endpointUri);

                queryBaseUriBuilder.Scheme = "https";
                queryBaseUriBuilder.Port = instancePortMinimum + i;
                queryBaseUriBuilder.Path = "search/query";

                return new Instance(
                    ProductionSlot,
                    i,
                    diagUriBuilder.Uri.ToString(),
                    queryBaseUriBuilder.Uri.ToString(),
                    regionInformation.Region);
            })
                   .ToList());
        }
Beispiel #2
0
        public IReadOnlyList <Instance> GetSearchEndpoints(RegionInformation regionInformation)
        {
            switch (regionInformation.ServiceType)
            {
            case ServiceType.AzureSearch:
                return(GetInstances(new Uri(regionInformation.BaseUrl), instanceCount: 1, regionInformation: regionInformation, serviceType: ServiceType.AzureSearch));

            default:
                throw new NotImplementedException($"Unknown ServiceType: {regionInformation.ServiceType}");
            }
        }
        public async Task <IReadOnlyList <Instance> > GetSearchEndpointsAsync(
            RegionInformation regionInformation,
            CancellationToken token)
        {
            var result = await _azureManagementApiWrapper.GetCloudServicePropertiesAsync(
                _configuration.Value.Subscription,
                regionInformation.ResourceGroup,
                regionInformation.ServiceName,
                ProductionSlot,
                token);

            var cloudService = AzureHelper.ParseCloudServiceProperties(result);

            var instances = GetInstances(cloudService.Uri, cloudService.InstanceCount, regionInformation);

            return(instances);
        }
Beispiel #4
0
        private List <Instance> GetInstances(Uri endpointUri, int instanceCount, RegionInformation regionInformation, ServiceType serviceType)
        {
            switch (serviceType)
            {
            case ServiceType.AzureSearch:
                _logger.LogInformation(
                    "{ServiceType}: Testing for region {Region}.",
                    ServiceType.AzureSearch,
                    regionInformation.Region);
                break;
            }

            return(Enumerable
                   .Range(0, instanceCount)
                   .Select(i =>
            {
                var diagUriBuilder = new UriBuilder(endpointUri);

                diagUriBuilder.Scheme = "https";
                diagUriBuilder.Path = "search/diag";

                var queryBaseUriBuilder = new UriBuilder(endpointUri);

                queryBaseUriBuilder.Scheme = "https";
                queryBaseUriBuilder.Path = "search/query";

                return new Instance(
                    ProductionSlot,
                    i,
                    diagUriBuilder.Uri.ToString(),
                    queryBaseUriBuilder.Uri.ToString(),
                    regionInformation.Region,
                    serviceType);
            })
                   .ToList());
        }