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

Commit d6a212a

Browse files
author
Christy Henriksson
authored
Update Stats.RefreshClientDimension to use ISqlConnectionFactory (#428)
1 parent f6ed450 commit d6a212a

4 files changed

Lines changed: 38 additions & 73 deletions

File tree

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,30 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
55
</startup>
66
<runtime>
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
88
<dependentAssembly>
9-
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
10-
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
9+
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
10+
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
1111
</dependentAssembly>
1212
<dependentAssembly>
13-
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
14-
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
13+
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
14+
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
1515
</dependentAssembly>
1616
<dependentAssembly>
17-
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
18-
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
17+
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
18+
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
1919
</dependentAssembly>
2020
<dependentAssembly>
21-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
22-
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
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"/>
2323
</dependentAssembly>
2424
<dependentAssembly>
25-
<assemblyIdentity name="Microsoft.Azure.KeyVault" publicKeyToken="31bf3856ad364e35" culture="neutral" />
26-
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
27-
</dependentAssembly>
28-
<dependentAssembly>
29-
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform" publicKeyToken="31bf3856ad364e35" culture="neutral" />
30-
<bindingRedirect oldVersion="0.0.0.0-3.13.4.878" newVersion="3.13.4.878" />
31-
</dependentAssembly>
32-
<dependentAssembly>
33-
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
34-
<bindingRedirect oldVersion="0.0.0.0-3.13.4.878" newVersion="3.13.4.878" />
35-
</dependentAssembly>
36-
<dependentAssembly>
37-
<assemblyIdentity name="NuGet.Services.KeyVault" publicKeyToken="31bf3856ad364e35" culture="neutral" />
38-
<bindingRedirect oldVersion="0.0.0.0-2.2.3.0" newVersion="2.2.3.0" />
39-
</dependentAssembly>
40-
<dependentAssembly>
41-
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral" />
42-
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
25+
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
26+
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0"/>
4327
</dependentAssembly>
4428
</assemblyBinding>
4529
</runtime>
46-
</configuration>
30+
</configuration>

src/Stats.RefreshClientDimension/RefreshClientDimensionJob.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
using System;
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.ComponentModel.Design;
4-
using System.Data.SqlClient;
57
using System.Linq;
68
using System.Threading.Tasks;
79
using Microsoft.Extensions.Logging;
810
using NuGet.Jobs;
11+
using NuGet.Services.KeyVault;
12+
using NuGet.Services.Sql;
913
using Stats.ImportAzureCdnStatistics;
1014

1115
namespace Stats.RefreshClientDimension
1216
{
1317
public class RefreshClientDimensionJob : JobBase
1418
{
15-
private static SqlConnectionStringBuilder _targetDatabase;
19+
private static ISqlConnectionFactory _statisticsDbConnectionFactory;
1620
private static string _targetClientName;
1721
private static string _userAgentFilter;
1822

1923
public override void Init(IServiceContainer serviceContainer, IDictionary<string, string> jobArgsDictionary)
2024
{
21-
var databaseConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
22-
_targetDatabase = new SqlConnectionStringBuilder(databaseConnectionString);
25+
var secretInjector = (ISecretInjector)serviceContainer.GetService(typeof(ISecretInjector));
26+
var statisticsDbConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.StatisticsDatabase);
27+
_statisticsDbConnectionFactory = new AzureSqlConnectionFactory(statisticsDbConnectionString, secretInjector);
2328

2429
_targetClientName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "TargetClientName");
2530
_userAgentFilter = JobConfigurationManager.TryGetArgument(jobArgsDictionary, "UserAgentFilter");
2631
}
2732

2833
public override async Task Run()
2934
{
30-
using (var connection = await _targetDatabase.ConnectTo())
35+
using (var connection = await _statisticsDbConnectionFactory.CreateAsync())
3136
{
3237
IDictionary<string, Tuple<int, int>> linkedUserAgents;
3338

src/Stats.RefreshClientDimension/Stats.RefreshClientDimension.csproj

Lines changed: 14 additions & 19 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,9 +9,10 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>Stats.RefreshClientDimension</RootNamespace>
1111
<AssemblyName>Stats.RefreshClientDimension</AssemblyName>
12-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
<TargetFrameworkProfile />
1516
</PropertyGroup>
1617
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1718
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,12 +34,6 @@
3334
<WarningLevel>4</WarningLevel>
3435
</PropertyGroup>
3536
<ItemGroup>
36-
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
37-
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.0\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
38-
</Reference>
39-
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
40-
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
41-
</Reference>
4237
<Reference Include="System" />
4338
<Reference Include="System.Core" />
4439
<Reference Include="System.Xml.Linq" />
@@ -47,9 +42,6 @@
4742
<Reference Include="System.Data" />
4843
<Reference Include="System.Net.Http" />
4944
<Reference Include="System.Xml" />
50-
<Reference Include="UAParser, Version=1.2.0.0, Culture=neutral, PublicKeyToken=f7377bf021646069, processorArchitecture=MSIL">
51-
<HintPath>..\..\packages\UAParser.1.2.0.0\lib\net35-Client\UAParser.dll</HintPath>
52-
</Reference>
5345
</ItemGroup>
5446
<ItemGroup>
5547
<Compile Include="..\Stats.ImportAzureCdnStatistics\ClientDimensionTableType.cs">
@@ -82,21 +74,24 @@
8274
<LogicalName>knownclients.yaml</LogicalName>
8375
</EmbeddedResource>
8476
<None Include="App.config" />
85-
<None Include="packages.config" />
8677
</ItemGroup>
8778
<ItemGroup>
8879
<ProjectReference Include="..\NuGet.Jobs.Common\NuGet.Jobs.Common.csproj">
8980
<Project>{4B4B1EFB-8F33-42E6-B79F-54E7F3293D31}</Project>
9081
<Name>NuGet.Jobs.Common</Name>
9182
</ProjectReference>
9283
</ItemGroup>
84+
<ItemGroup>
85+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions">
86+
<Version>1.0.0</Version>
87+
</PackageReference>
88+
<PackageReference Include="NuGet.Services.Sql">
89+
<Version>2.25.0-master-30453</Version>
90+
</PackageReference>
91+
<PackageReference Include="UAParser">
92+
<Version>1.2.0</Version>
93+
</PackageReference>
94+
</ItemGroup>
9395
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9496
<Import Project="..\..\build\sign.targets" Condition="Exists('..\..\build\sign.targets')" />
95-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
96-
Other similar extension points exist, see Microsoft.Common.targets.
97-
<Target Name="BeforeBuild">
98-
</Target>
99-
<Target Name="AfterBuild">
100-
</Target>
101-
-->
10297
</Project>

src/Stats.RefreshClientDimension/packages.config

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

0 commit comments

Comments
 (0)