Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit e030495

Browse files
author
Christy Henriksson
authored
Update Stats.RollupDownloadFacts to use ISqlConnectionFactory (#429)
1 parent d6a212a commit e030495

4 files changed

Lines changed: 37 additions & 129 deletions

File tree

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
55
</startup>
66
<runtime>
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8-
<dependentAssembly>
9-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
10-
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
11-
</dependentAssembly>
128
<dependentAssembly>
139
<assemblyIdentity name="Serilog" publicKeyToken="24c2f752a8e58a10" culture="neutral" />
1410
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
@@ -17,18 +13,6 @@
1713
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
1814
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
1915
</dependentAssembly>
20-
<dependentAssembly>
21-
<assemblyIdentity name="Microsoft.Azure.KeyVault" publicKeyToken="31bf3856ad364e35" culture="neutral" />
22-
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
23-
</dependentAssembly>
24-
<dependentAssembly>
25-
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" />
26-
<bindingRedirect oldVersion="0.0.0.0-3.13.4.878" newVersion="3.13.4.878" />
27-
</dependentAssembly>
28-
<dependentAssembly>
29-
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
30-
<bindingRedirect oldVersion="0.0.0.0-3.13.4.878" newVersion="3.13.4.878" />
31-
</dependentAssembly>
3216
<dependentAssembly>
3317
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
3418
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
@@ -41,10 +25,6 @@
4125
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
4226
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
4327
</dependentAssembly>
44-
<dependentAssembly>
45-
<assemblyIdentity name="NuGet.Services.KeyVault" publicKeyToken="31bf3856ad364e35" culture="neutral" />
46-
<bindingRedirect oldVersion="0.0.0.0-2.2.3.0" newVersion="2.2.3.0" />
47-
</dependentAssembly>
4828
</assemblyBinding>
4929
</runtime>
5030
</configuration>

src/Stats.RollUpDownloadFacts/Job.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
using System.Threading.Tasks;
1010
using Microsoft.Extensions.Logging;
1111
using NuGet.Jobs;
12+
using NuGet.Services.KeyVault;
13+
using NuGet.Services.Sql;
1214

1315
namespace Stats.RollUpDownloadFacts
1416
{
@@ -19,20 +21,21 @@ public class Job
1921
private const string _endTemplateFactDownloadDeletion = " records from [dbo].[Fact_Download]";
2022
private const int DefaultMinAgeInDays = 43;
2123
private static int _minAgeInDays;
22-
private static SqlConnectionStringBuilder _targetDatabase;
24+
private static ISqlConnectionFactory _statisticsDbConnectionFactory;
2325

2426
public override void Init(IServiceContainer serviceContainer, IDictionary<string, string> jobArgsDictionary)
2527
{
26-
var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
27-
_targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString);
28+
var secretInjector = (ISecretInjector)serviceContainer.GetService(typeof(ISecretInjector));
29+
var statisticsDbConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
30+
_statisticsDbConnectionFactory = new AzureSqlConnectionFactory(statisticsDbConnectionString, secretInjector);
2831

2932
_minAgeInDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, JobArgumentNames.MinAgeInDays) ?? DefaultMinAgeInDays;
3033
Logger.LogInformation("Min age in days: {MinAgeInDays}", _minAgeInDays);
3134
}
3235

3336
public override async Task Run()
3437
{
35-
using (var connection = await _targetDatabase.ConnectTo())
38+
using (var connection = await _statisticsDbConnectionFactory.CreateAsync())
3639
{
3740
connection.InfoMessage -= OnSqlConnectionInfoMessage;
3841
connection.InfoMessage += OnSqlConnectionInfoMessage;
Lines changed: 29 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -9,8 +9,9 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>Stats.RollUpDownloadFacts</RootNamespace>
1111
<AssemblyName>Stats.RollUpDownloadFacts</AssemblyName>
12-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1415
<TargetFrameworkProfile />
1516
<NuGetPackageImportStamp>
1617
</NuGetPackageImportStamp>
@@ -35,67 +36,13 @@
3536
<WarningLevel>4</WarningLevel>
3637
</PropertyGroup>
3738
<ItemGroup>
38-
<Reference Include="Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
39-
<HintPath>..\..\packages\Microsoft.ApplicationInsights.2.1.0\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
40-
</Reference>
41-
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
42-
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
43-
</Reference>
44-
<Reference Include="Microsoft.Extensions.Logging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
45-
<HintPath>..\..\packages\Microsoft.Extensions.Logging.1.0.0\lib\netstandard1.1\Microsoft.Extensions.Logging.dll</HintPath>
46-
</Reference>
47-
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
48-
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.0\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
49-
</Reference>
50-
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
51-
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
52-
</Reference>
53-
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
54-
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
55-
</Reference>
56-
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
57-
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
58-
</Reference>
59-
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
60-
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
61-
</Reference>
62-
<Reference Include="NuGet.Services.Logging, Version=2.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63-
<HintPath>..\..\packages\NuGet.Services.Logging.2.2.3\lib\net452\NuGet.Services.Logging.dll</HintPath>
64-
</Reference>
65-
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
66-
<HintPath>..\..\packages\Serilog.2.2.1\lib\net45\Serilog.dll</HintPath>
67-
</Reference>
68-
<Reference Include="Serilog.Enrichers.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
69-
<HintPath>..\..\packages\Serilog.Enrichers.Environment.2.1.0\lib\net45\Serilog.Enrichers.Environment.dll</HintPath>
70-
</Reference>
71-
<Reference Include="Serilog.Enrichers.Process, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
72-
<HintPath>..\..\packages\Serilog.Enrichers.Process.2.0.0\lib\net45\Serilog.Enrichers.Process.dll</HintPath>
73-
</Reference>
74-
<Reference Include="Serilog.Extensions.Logging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
75-
<HintPath>..\..\packages\Serilog.Extensions.Logging.1.2.0\lib\net45\Serilog.Extensions.Logging.dll</HintPath>
76-
</Reference>
77-
<Reference Include="Serilog.Sinks.ApplicationInsights, Version=2.2.1.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
78-
<HintPath>..\..\packages\Serilog.Sinks.ApplicationInsights.2.2.1\lib\net45\Serilog.Sinks.ApplicationInsights.dll</HintPath>
79-
</Reference>
80-
<Reference Include="Serilog.Sinks.ColoredConsole, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
81-
<HintPath>..\..\packages\Serilog.Sinks.ColoredConsole.2.0.0\lib\net45\Serilog.Sinks.ColoredConsole.dll</HintPath>
82-
</Reference>
83-
<Reference Include="SerilogTraceListener, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9398e41289d9b801, processorArchitecture=MSIL">
84-
<HintPath>..\..\packages\SerilogTraceListener.2.0.10027\lib\net45\SerilogTraceListener.dll</HintPath>
85-
</Reference>
8639
<Reference Include="System" />
8740
<Reference Include="System.ComponentModel.Composition" />
8841
<Reference Include="System.Core" />
8942
<Reference Include="Microsoft.CSharp" />
9043
<Reference Include="System.Data" />
9144
<Reference Include="System.Net" />
9245
<Reference Include="System.Net.Http" />
93-
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
94-
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
95-
</Reference>
96-
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
97-
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
98-
</Reference>
9946
<Reference Include="System.Net.Http.WebRequest" />
10047
<Reference Include="System.XML" />
10148
</ItemGroup>
@@ -107,7 +54,6 @@
10754
</ItemGroup>
10855
<ItemGroup>
10956
<None Include="App.config" />
110-
<None Include="packages.config" />
11157
<None Include="Scripts\*" />
11258
<None Include="Stats.RollUpDownloadFacts.nuspec" />
11359
</ItemGroup>
@@ -121,20 +67,32 @@
12167
<Name>Stats.AzureCdnLogs.Common</Name>
12268
</ProjectReference>
12369
</ItemGroup>
70+
<ItemGroup>
71+
<PackageReference Include="Microsoft.ApplicationInsights">
72+
<Version>2.1.0</Version>
73+
</PackageReference>
74+
<PackageReference Include="Microsoft.Data.Edm">
75+
<Version>5.7.0</Version>
76+
</PackageReference>
77+
<PackageReference Include="Microsoft.Data.OData">
78+
<Version>5.7.0</Version>
79+
</PackageReference>
80+
<PackageReference Include="Microsoft.Data.Services.Client">
81+
<Version>5.7.0</Version>
82+
</PackageReference>
83+
<PackageReference Include="Microsoft.Extensions.Logging">
84+
<Version>1.0.0</Version>
85+
</PackageReference>
86+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions">
87+
<Version>1.0.0</Version>
88+
</PackageReference>
89+
<PackageReference Include="NuGet.Services.Logging">
90+
<Version>2.2.3</Version>
91+
</PackageReference>
92+
<PackageReference Include="NuGet.Services.Sql">
93+
<Version>2.25.0-master-30453</Version>
94+
</PackageReference>
95+
</ItemGroup>
12496
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
12597
<Import Project="..\..\build\sign.targets" Condition="Exists('..\..\build\sign.targets')" />
126-
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
127-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
128-
<PropertyGroup>
129-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
130-
</PropertyGroup>
131-
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
132-
</Target>
133-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
134-
Other similar extension points exist, see Microsoft.Common.targets.
135-
<Target Name="BeforeBuild">
136-
</Target>
137-
<Target Name="AfterBuild">
138-
</Target>
139-
-->
14098
</Project>

src/Stats.RollUpDownloadFacts/packages.config

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)