77using Azure . Mcp . Core . Services . Azure ;
88using Azure . Mcp . Core . Services . Azure . Subscription ;
99using Azure . Mcp . Core . Services . Azure . Tenant ;
10- using Azure . Mcp . Core . Services . Http ;
1110using Azure . Mcp . Tools . ResourceHealth . Models ;
1211using Azure . Mcp . Tools . ResourceHealth . Models . Internal ;
1312
1413namespace Azure . Mcp . Tools . ResourceHealth . Services ;
1514
16- public class ResourceHealthService ( ISubscriptionService subscriptionService , ITenantService tenantService , IHttpClientService httpClientService )
15+ public class ResourceHealthService ( ISubscriptionService subscriptionService , ITenantService tenantService , IHttpClientFactory httpClientFactory )
1716 : BaseAzureService ( tenantService ) , IResourceHealthService
1817{
1918 private readonly ISubscriptionService _subscriptionService = subscriptionService ?? throw new ArgumentNullException ( nameof ( subscriptionService ) ) ;
20- private readonly IHttpClientService _httpClientService = httpClientService ?? throw new ArgumentNullException ( nameof ( httpClientService ) ) ;
19+ private readonly IHttpClientFactory _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException ( nameof ( httpClientFactory ) ) ;
2120
2221 private const string AzureManagementBaseUrl = "https://management.azure.com" ;
2322 private const string ResourceHealthApiVersion = "2025-05-01" ;
@@ -36,7 +35,8 @@ public async Task<AvailabilityStatus> GetAvailabilityStatusAsync(
3635 new TokenRequestContext ( [ $ "{ AzureManagementBaseUrl } /.default"] ) ,
3736 cancellationToken ) ;
3837
39- using var client = _httpClientService . CreateClient ( new Uri ( AzureManagementBaseUrl ) ) ;
38+ var client = _httpClientFactory . CreateClient ( ) ;
39+ client . BaseAddress = new Uri ( AzureManagementBaseUrl ) ;
4040 client . DefaultRequestHeaders . Authorization = new System . Net . Http . Headers . AuthenticationHeaderValue ( "Bearer" , token . Token ) ;
4141
4242 var url = $ "{ resourceId } /providers/Microsoft.ResourceHealth/availabilityStatuses/current?api-version={ ResourceHealthApiVersion } ";
@@ -83,7 +83,8 @@ public async Task<List<AvailabilityStatus>> ListAvailabilityStatusesAsync(
8383 new TokenRequestContext ( [ $ "{ AzureManagementBaseUrl } /.default"] ) ,
8484 cancellationToken ) ;
8585
86- using var client = _httpClientService . CreateClient ( new Uri ( AzureManagementBaseUrl ) ) ;
86+ var client = _httpClientFactory . CreateClient ( ) ;
87+ client . BaseAddress = new Uri ( AzureManagementBaseUrl ) ;
8788 client . DefaultRequestHeaders . Authorization = new System . Net . Http . Headers . AuthenticationHeaderValue ( "Bearer" , token . Token ) ;
8889
8990 var url = resourceGroup != null
@@ -137,7 +138,8 @@ public async Task<List<ServiceHealthEvent>> ListServiceHealthEventsAsync(
137138 new TokenRequestContext ( [ $ "{ AzureManagementBaseUrl } /.default"] ) ,
138139 cancellationToken ) ;
139140
140- using var client = _httpClientService . CreateClient ( new Uri ( AzureManagementBaseUrl ) ) ;
141+ var client = _httpClientFactory . CreateClient ( ) ;
142+ client . BaseAddress = new Uri ( AzureManagementBaseUrl ) ;
141143 client . DefaultRequestHeaders . Authorization = new System . Net . Http . Headers . AuthenticationHeaderValue ( "Bearer" , token . Token ) ;
142144
143145 // Build OData filter - using correct property paths for Azure Resource Health API
0 commit comments