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

Commit c967ede

Browse files
author
Scott Bommarito
authored
Merge pull request #141 from NuGet/dev
[ReleasePrep][2017.04.28]RI of dev into master
2 parents b58b329 + ca2edbe commit c967ede

37 files changed

Lines changed: 1036 additions & 203 deletions

src/Gallery.CredentialExpiration/Gallery.CredentialExpiration.csproj

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@
3636
<Reference Include="Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
3737
<HintPath>..\..\packages\Microsoft.ApplicationInsights.2.1.0\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
3838
</Reference>
39+
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
40+
<HintPath>..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
43+
<HintPath>..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
44+
<Private>True</Private>
45+
</Reference>
46+
<Reference Include="Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
47+
<HintPath>..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
48+
<Private>True</Private>
49+
</Reference>
50+
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
51+
<HintPath>..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
52+
<Private>True</Private>
53+
</Reference>
3954
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
4055
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
4156
</Reference>
@@ -45,12 +60,18 @@
4560
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
4661
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.0\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
4762
</Reference>
63+
<Reference Include="Microsoft.WindowsAzure.Storage, Version=7.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<HintPath>..\..\packages\WindowsAzure.Storage.7.1.2\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
65+
</Reference>
4866
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4967
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
5068
</Reference>
5169
<Reference Include="NuGet.Services.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5270
<HintPath>..\..\packages\NuGet.Services.Logging.2.1.1\lib\net452\NuGet.Services.Logging.dll</HintPath>
5371
</Reference>
72+
<Reference Include="NuGet.Services.Storage, Version=2.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
73+
<HintPath>..\..\packages\NuGet.Services.Storage.2.1.3\lib\net452\NuGet.Services.Storage.dll</HintPath>
74+
</Reference>
5475
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
5576
<HintPath>..\..\packages\Serilog.2.2.1\lib\net45\Serilog.dll</HintPath>
5677
</Reference>
@@ -75,6 +96,10 @@
7596
<Reference Include="System" />
7697
<Reference Include="System.ComponentModel.Composition" />
7798
<Reference Include="System.Core" />
99+
<Reference Include="System.Spatial, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
100+
<HintPath>..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath>
101+
<Private>True</Private>
102+
</Reference>
78103
<Reference Include="System.Xml.Linq" />
79104
<Reference Include="System.Data.DataSetExtensions" />
80105
<Reference Include="Microsoft.CSharp" />
@@ -100,7 +125,9 @@
100125
<None Include="Gallery.CredentialExpiration.nuspec">
101126
<SubType>Designer</SubType>
102127
</None>
103-
<None Include="packages.config" />
128+
<None Include="packages.config">
129+
<SubType>Designer</SubType>
130+
</None>
104131
<None Include="Scripts\Functions.ps1" />
105132
<None Include="Scripts\Gallery.CredentialExpiration.cmd" />
106133
<None Include="Scripts\PostDeploy.ps1" />

src/Gallery.CredentialExpiration/Job.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
using System.Collections.Concurrent;
66
using System.Collections.Generic;
77
using System.Data.SqlClient;
8-
using System.IO;
98
using System.Linq;
109
using System.Net;
1110
using System.Net.Mail;
11+
using System.Threading;
1212
using System.Threading.Tasks;
1313
using Gallery.CredentialExpiration.Models;
1414
using Microsoft.Extensions.Logging;
15+
using Microsoft.WindowsAzure.Storage;
1516
using Newtonsoft.Json;
1617
using NuGet.Jobs;
1718
using NuGet.Services.Logging;
19+
using NuGet.Services.Storage;
1820

1921
namespace Gallery.CredentialExpiration
2022
{
@@ -38,6 +40,8 @@ public class Job : JobBase
3840
private int _allowEmailResendAfterDays = 7;
3941
private int _warnDaysBeforeExpiration = 10;
4042

43+
private Storage _storage;
44+
4145
private ILogger _logger;
4246

4347
public override bool Init(IDictionary<string, string> jobArgsDictionary)
@@ -70,6 +74,13 @@ public override bool Init(IDictionary<string, string> jobArgsDictionary)
7074

7175
_allowEmailResendAfterDays = JobConfigurationManager.TryGetIntArgument(jobArgsDictionary, MyJobArgumentNames.AllowEmailResendAfterDays)
7276
?? _allowEmailResendAfterDays;
77+
78+
var storageConnectionString = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.DataStorageAccount);
79+
var storageContainerName = JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.ContainerName);
80+
81+
var csa = CloudStorageAccount.Parse(storageConnectionString);
82+
var storageFactory = new AzureStorageFactory(csa, storageContainerName, loggerFactory);
83+
_storage = storageFactory.Create();
7384
}
7485
catch (Exception exception)
7586
{
@@ -88,11 +99,11 @@ public override async Task<bool> Run()
8899
List<ExpiredCredentialData> expiredCredentials = null;
89100

90101
// Who did we contact before?
91-
if (File.Exists(_cursorFile))
102+
if (_storage.Exists(_cursorFile))
92103
{
104+
string content = await _storage.LoadString(_storage.ResolveUri(_cursorFile), CancellationToken.None);
93105
// Load from cursor
94-
var contactedUsers = JsonConvert.DeserializeObject<Dictionary<string, DateTimeOffset>>(
95-
File.ReadAllText(_cursorFile));
106+
var contactedUsers = JsonConvert.DeserializeObject<Dictionary<string, DateTimeOffset>>(content);
96107

97108
// Clean older entries (contacted in last _allowEmailResendAfterDays)
98109
var referenceDate = DateTimeOffset.UtcNow.AddDays(-1 * _allowEmailResendAfterDays);
@@ -171,7 +182,9 @@ public override async Task<bool> Run()
171182
{
172183
// Make sure we know who has been contacted today, so they do not get double
173184
// e-mail notifications.
174-
File.WriteAllText(_cursorFile, JsonConvert.SerializeObject(_contactedUsers));
185+
string json = JsonConvert.SerializeObject(_contactedUsers);
186+
var content = new StringStorageContent(json, "application/json");
187+
await _storage.Save(_storage.ResolveUri(_cursorFile), content, CancellationToken.None);
175188
}
176189

177190
return true;

src/Gallery.CredentialExpiration/Scripts/Gallery.CredentialExpiration.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cd bin
99

1010
REM SmtpUri is expected to be of the format: smtps://username:password@host:port. Note that if username contains an "@", you need to URI encode it!
1111

12-
start /w gallery.credentialexpiration.exe -ConsoleLogOnly -VaultName "#{Deployment.Azure.KeyVault.VaultName}" -ClientId "#{Deployment.Azure.KeyVault.ClientId}" -CertificateThumbprint "#{Deployment.Azure.KeyVault.CertificateThumbprint}" -WhatIf #{Jobs.gallery.credentialexpiration.WhatIf} -WarnDaysBeforeExpiration #{Jobs.gallery.credentialexpiration.WarnDaysBeforeExpiration} -MailFrom "#{Jobs.gallery.credentialexpiration.MailFrom}" -GalleryBrand "#{Jobs.gallery.credentialexpiration.GalleryBrand}" -GalleryAccountUrl "#{Jobs.gallery.credentialexpiration.GalleryAccountUrl}" -SmtpUri "#{Jobs.gallery.credentialexpiration.SmtpUri}" -GalleryDatabase "#{Jobs.gallery.credentialexpiration.GalleryDatabase}" -InstrumentationKey "#{Jobs.gallery.credentialexpiration.InstrumentationKey}" -verbose true -Interval #{Jobs.gallery.credentialexpiration.Interval}
12+
start /w gallery.credentialexpiration.exe -ConsoleLogOnly -VaultName "#{Deployment.Azure.KeyVault.VaultName}" -ClientId "#{Deployment.Azure.KeyVault.ClientId}" -CertificateThumbprint "#{Deployment.Azure.KeyVault.CertificateThumbprint}" -WhatIf #{Jobs.gallery.credentialexpiration.WhatIf} -WarnDaysBeforeExpiration #{Jobs.gallery.credentialexpiration.WarnDaysBeforeExpiration} -MailFrom "#{Jobs.gallery.credentialexpiration.MailFrom}" -GalleryBrand "#{Jobs.gallery.credentialexpiration.GalleryBrand}" -GalleryAccountUrl "#{Jobs.gallery.credentialexpiration.GalleryAccountUrl}" -SmtpUri "#{Jobs.gallery.credentialexpiration.SmtpUri}" -GalleryDatabase "#{Jobs.gallery.credentialexpiration.GalleryDatabase}" -InstrumentationKey "#{Jobs.gallery.credentialexpiration.InstrumentationKey}" -verbose true -Interval #{Jobs.gallery.credentialexpiration.Interval} -DataStorageAccount "#{Jobs.gallery.credentialexpiration.Storage.Primary}" -ContainerName "#{Jobs.gallery.credentialexpiration.ContainerName}"
1313

1414
echo "Finished #{Jobs.gallery.credentialexpiration.Title}"
1515

src/Gallery.CredentialExpiration/packages.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.ApplicationInsights" version="2.1.0" targetFramework="net452" />
4+
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net452" />
5+
<package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net452" />
6+
<package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net452" />
7+
<package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net452" />
48
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0" targetFramework="net452" />
59
<package id="Microsoft.Extensions.Logging" version="1.0.0" targetFramework="net452" />
610
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0" targetFramework="net452" />
711
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
812
<package id="NuGet.Services.Logging" version="2.1.1" targetFramework="net452" />
13+
<package id="NuGet.Services.Storage" version="2.1.3" targetFramework="net452" />
914
<package id="Serilog" version="2.2.1" targetFramework="net452" />
1015
<package id="Serilog.Enrichers.Environment" version="2.1.0" targetFramework="net452" />
1116
<package id="Serilog.Enrichers.Process" version="2.0.0" targetFramework="net452" />
@@ -25,5 +30,7 @@
2530
<package id="System.Runtime" version="4.1.0" targetFramework="net452" />
2631
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net452" />
2732
<package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="net452" />
33+
<package id="System.Spatial" version="5.6.4" targetFramework="net452" />
2834
<package id="System.Threading" version="4.0.11" targetFramework="net452" />
35+
<package id="WindowsAzure.Storage" version="7.1.2" targetFramework="net452" />
2936
</packages>

src/NuGet.Jobs.Common/Configuration/JobArgumentNames.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public static class JobArgumentNames
9898
// Arguments specific to VCS validation task
9999
public const string VcsValidatorServiceUrl = "VcsValidatorServiceUrl";
100100
public const string VcsValidatorCallbackUrl = "VcsValidatorCallbackUrl";
101-
public const string VcsValidatorAlias = "VcsValidatorAlias";
101+
public const string VcsContactAlias = "VcsContactAlias";
102+
public const string VcsValidatorSubmitterAlias = "VcsValidatorAlias";
102103
public const string VcsPackageUrlTemplate = "VcsPackageUrlTemplate";
103104

104105
// Key Vault

src/Stats.CreateAzureCdnWarehouseReports/DownloadCountReport.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Newtonsoft.Json;
1212
using Newtonsoft.Json.Linq;
1313
using NuGet;
14+
using NuGet.Versioning;
1415

1516
namespace Stats.CreateAzureCdnWarehouseReports
1617
{

src/Stats.CreateAzureCdnWarehouseReports/Stats.CreateAzureCdnWarehouseReports.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@
7171
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
7272
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
7373
</Reference>
74-
<Reference Include="Microsoft.Web.XmlTransform, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
75-
<HintPath>..\..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll</HintPath>
76-
</Reference>
7774
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7875
<HintPath>..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.1\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
7976
</Reference>
@@ -83,12 +80,12 @@
8380
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
8481
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
8582
</Reference>
86-
<Reference Include="NuGet.Core, Version=2.10.1.766, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
87-
<HintPath>..\..\packages\NuGet.Core.2.10.1\lib\net40-Client\NuGet.Core.dll</HintPath>
88-
</Reference>
8983
<Reference Include="NuGet.Services.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
9084
<HintPath>..\..\packages\NuGet.Services.Logging.2.1.1\lib\net452\NuGet.Services.Logging.dll</HintPath>
9185
</Reference>
86+
<Reference Include="NuGet.Versioning, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
87+
<HintPath>..\..\packages\NuGet.Versioning.4.3.0-preview1-2524\lib\net45\NuGet.Versioning.dll</HintPath>
88+
</Reference>
9289
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
9390
<HintPath>..\..\packages\Serilog.2.2.1\lib\net45\Serilog.dll</HintPath>
9491
</Reference>

src/Stats.CreateAzureCdnWarehouseReports/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
<package id="Microsoft.Extensions.Logging" version="1.0.0" targetFramework="net452" />
1414
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0" targetFramework="net452" />
1515
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
16-
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net452" />
1716
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.1" targetFramework="net452" />
1817
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
19-
<package id="NuGet.Core" version="2.10.1" targetFramework="net452" />
2018
<package id="NuGet.Services.Logging" version="2.1.1" targetFramework="net452" />
19+
<package id="NuGet.Versioning" version="4.3.0-preview1-2524" targetFramework="net452" />
2120
<package id="Serilog" version="2.2.1" targetFramework="net452" />
2221
<package id="Serilog.Enrichers.Environment" version="2.1.0" targetFramework="net452" />
2322
<package id="Serilog.Enrichers.Process" version="2.0.0" targetFramework="net452" />

src/Stats.ImportAzureCdnStatistics/PackageStatisticsParser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using NuGet;
5+
using NuGet.Versioning;
56
using Stats.AzureCdnLogs.Common;
67

78
namespace Stats.ImportAzureCdnStatistics

src/Stats.ImportAzureCdnStatistics/Stats.ImportAzureCdnStatistics.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@
8383
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
8484
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
8585
</Reference>
86-
<Reference Include="NuGet.Core, Version=2.10.1.766, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
87-
<HintPath>..\..\packages\NuGet.Core.2.10.1\lib\net40-Client\NuGet.Core.dll</HintPath>
88-
</Reference>
8986
<Reference Include="NuGet.Services.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
9087
<HintPath>..\..\packages\NuGet.Services.Logging.2.1.1\lib\net452\NuGet.Services.Logging.dll</HintPath>
9188
</Reference>
89+
<Reference Include="NuGet.Versioning, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
90+
<HintPath>..\..\packages\NuGet.Versioning.4.3.0-preview1-2524\lib\net45\NuGet.Versioning.dll</HintPath>
91+
</Reference>
9292
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
9393
<HintPath>..\..\packages\Serilog.2.2.1\lib\net45\Serilog.dll</HintPath>
9494
</Reference>

0 commit comments

Comments
 (0)