|
1 | | -// Copyright (c) .NET Foundation. All rights reserved. |
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
3 | 3 |
|
4 | 4 | using System; |
|
27 | 27 | using NuGetGallery.Features; |
28 | 28 | using NuGetGallery.Infrastructure.Authentication; |
29 | 29 | using NuGetGallery.Security; |
| 30 | +using ConfigConstants = NuGet.Services.Configuration.Constants; |
30 | 31 |
|
31 | 32 | namespace NuGetGallery.AccountDeleter |
32 | 33 | { |
@@ -104,6 +105,13 @@ protected override void ConfigureJobServices(IServiceCollection services, IConfi |
104 | 105 | services.AddScoped<ITelemetryClient, TelemetryClientWrapper>( |
105 | 106 | sp => TelemetryClientWrapper.UseTelemetryConfiguration(ApplicationInsightsConfiguration.TelemetryConfiguration)); |
106 | 107 |
|
| 108 | + services.AddScoped<ICloudBlobClient>(serviceProvider => |
| 109 | + { |
| 110 | + var options = serviceProvider.GetRequiredService<IOptionsSnapshot<AccountDeleteConfiguration>>(); |
| 111 | + return CloudBlobClientWrapper.UsingMsi(options.Value.GalleryStorageConnectionString, |
| 112 | + configurationRoot[ConfigConstants.StorageManagedIdentityClientIdPropertyName]); |
| 113 | + }); |
| 114 | + |
107 | 115 | ConfigureGalleryServices(services); |
108 | 116 | } |
109 | 117 |
|
@@ -160,14 +168,6 @@ protected void ConfigureGalleryServices(IServiceCollection services) |
160 | 168 | return new SupportRequestDbContext(connection); |
161 | 169 | }); |
162 | 170 |
|
163 | | - services.AddScoped<ICloudBlobClient>(sp => |
164 | | - { |
165 | | - var options = sp.GetRequiredService<IOptionsSnapshot<AccountDeleteConfiguration>>(); |
166 | | - var optionsSnapshot = options.Value; |
167 | | - |
168 | | - return new CloudBlobClientWrapper(optionsSnapshot.GalleryStorageConnectionString, readAccessGeoRedundant: true); |
169 | | - }); |
170 | | - |
171 | 171 | services.AddScoped<ITelemetryService, TelemetryService>(); |
172 | 172 | services.AddScoped<ISecurityPolicyService, SecurityPolicyService>(); |
173 | 173 | services.AddScoped<IAppConfiguration, GalleryConfiguration>(); |
|
0 commit comments