Skip to content

Commit c700723

Browse files
authored
Merge pull request #10340 from NuGet/dev
[ReleasePrep][2025.02.17]RI of dev into main
2 parents b26757e + 7e0c8f9 commit c700723

36 files changed

Lines changed: 366 additions & 306 deletions

File tree

src/NuGet.Jobs.Common/StorageAccountExtensions.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ public static TableServiceClient CreateTableServiceClient(
141141
}
142142

143143
StorageMsiConfiguration msiConfiguration = serviceProvider.GetRequiredService<IOptions<StorageMsiConfiguration>>().Value;
144-
return CreateTableServiceClientClient(
145-
msiConfiguration,
146-
storageConnectionString);
144+
return CreateTableServiceClient(msiConfiguration, storageConnectionString);
147145
}
148146

149147
public static IRegistrationBuilder<TableServiceClient, SimpleActivatorData, SingleRegistrationStyle> RegisterTableServiceClient<TConfiguration>(
@@ -165,9 +163,7 @@ public static IRegistrationBuilder<TableServiceClient, SimpleActivatorData, Sing
165163
IOptionsSnapshot<TConfiguration> options = c.Resolve<IOptionsSnapshot<TConfiguration>>();
166164
string storageConnectionString = getConnectionString(options.Value);
167165
StorageMsiConfiguration msiConfiguration = c.Resolve<IOptions<StorageMsiConfiguration>>().Value;
168-
return CreateTableServiceClientClient(
169-
msiConfiguration,
170-
storageConnectionString);
166+
return CreateTableServiceClient(msiConfiguration, storageConnectionString);
171167
});
172168
}
173169

@@ -277,27 +273,27 @@ public static BlobServiceClientFactory CreateBlobServiceClientFactory(
277273
}
278274
}
279275

280-
private static TableServiceClient CreateTableServiceClientClient(
276+
public static TableServiceClient CreateTableServiceClient(
281277
StorageMsiConfiguration msiConfiguration,
282278
string tableStorageConnectionString)
283279
{
284280
if (msiConfiguration.UseManagedIdentity)
285281
{
282+
Uri tableEndpointUri = new Uri(tableStorageConnectionString);
283+
286284
if (string.IsNullOrWhiteSpace(msiConfiguration.ManagedIdentityClientId))
287285
{
288-
return new TableServiceClient(new Uri(tableStorageConnectionString),
289-
new DefaultAzureCredential());
286+
return new TableServiceClient(tableEndpointUri, new DefaultAzureCredential());
290287
}
291288
else
292289
{
293-
return new TableServiceClient(new Uri(tableStorageConnectionString),
294-
new ManagedIdentityCredential(msiConfiguration.ManagedIdentityClientId));
290+
return new TableServiceClient(tableEndpointUri, new ManagedIdentityCredential(msiConfiguration.ManagedIdentityClientId));
295291
}
296292
}
297293

298294
// workaround for https://github.com/Azure/azure-sdk-for-net/issues/44373
299-
tableStorageConnectionString.Replace("SharedAccessSignature=?", "SharedAccessSignature=");
300-
return new TableServiceClient(tableStorageConnectionString);
295+
var connectionString = tableStorageConnectionString.Replace("SharedAccessSignature=?", "SharedAccessSignature=");
296+
return new TableServiceClient(connectionString);
301297
}
302298
}
303299
}

src/NuGet.Services.Cursor/NuGet.Services.Cursor.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<Description>Shared cursor classes</Description>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<PackageReference Include="System.Text.Json" />
11+
</ItemGroup>
12+
913
<ItemGroup>
1014
<ProjectReference Include="..\NuGet.Services.Storage\NuGet.Services.Storage.csproj" />
1115
</ItemGroup>

src/NuGet.Services.KeyVault/NuGet.Services.KeyVault.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<PackageReference Include="Azure.Security.KeyVault.Secrets" />
1313
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
1414
<PackageReference Include="Newtonsoft.Json" />
15+
<PackageReference Include="System.Text.Json" />
1516
</ItemGroup>
1617

1718
</Project>

src/NuGet.Services.ServiceBus/NuGet.Services.ServiceBus.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
1414
<PackageReference Include="Microsoft.Extensions.Logging" />
1515
<PackageReference Include="Newtonsoft.Json" />
16+
<PackageReference Include="System.Text.Json" />
1617
</ItemGroup>
1718

1819
<ItemGroup>

src/NuGet.Services.Status.Table/NuGet.Services.Status.Table.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="Azure.Core" />
1011
<PackageReference Include="Azure.Data.Tables" />
12+
<PackageReference Include="System.Text.Json" />
1113
</ItemGroup>
1214

1315
<ItemGroup>

src/NuGet.Services.Storage/AzureStorage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading;
1010
using System.Threading.Tasks;
1111
using Azure;
12+
using Azure.Data.Tables;
1213
using Azure.Storage.Blobs;
1314
using Azure.Storage.Blobs.Models;
1415
using Azure.Storage.Blobs.Specialized;
@@ -436,10 +437,11 @@ private Uri ResolvePathedUri(string filename)
436437
return ResolveUri(Path.Combine(_path, filename));
437438
}
438439

440+
// Returns the primary blob service URI from the connection string
439441
public static Uri GetPrimaryServiceUri(string storageConnectionString)
440442
{
441443
var tempClient = new BlobServiceClient(storageConnectionString);
442-
// if _storageConnectionString has SAS token, Uri will contain SAS signature, we need to strip it
444+
// if _storageConnectionString has SAS token, Uri will contain SAS signature, we need to strip it
443445
return new Uri(tempClient.Uri.GetLeftPart(UriPartial.Path));
444446
}
445447
}

src/NuGet.Services.Storage/BlobLeaseService.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Azure;
99
using Azure.Storage.Blobs;
1010
using Azure.Storage.Blobs.Specialized;
11+
using Microsoft.Extensions.Logging;
1112

1213
namespace NuGet.Services.Storage
1314
{
@@ -20,11 +21,11 @@ public class BlobLeaseService : IBlobLeaseService
2021
{
2122
private static readonly TimeSpan MinLeaseTime = TimeSpan.FromSeconds(15);
2223
private static readonly TimeSpan MaxLeaseTime = TimeSpan.FromSeconds(60);
23-
2424
private readonly BlobContainerClient _containerClient;
2525
private readonly string _basePath;
26+
private readonly bool _createBlobWhenMissing;
2627

27-
public BlobLeaseService(BlobServiceClient blobServiceClient, string containerName, string basePath)
28+
public BlobLeaseService(BlobServiceClient blobServiceClient, string containerName, string basePath, Boolean createBlobsWhenMissing = true)
2829
{
2930
if (blobServiceClient == null)
3031
{
@@ -34,13 +35,13 @@ public BlobLeaseService(BlobServiceClient blobServiceClient, string containerNam
3435
{
3536
throw new ArgumentException("The container name must be provided.", nameof(containerName));
3637
}
37-
if (string.IsNullOrEmpty(basePath))
38+
if (basePath == null)
3839
{
3940
throw new ArgumentException("The base path must be provided.", nameof(basePath));
4041
}
41-
4242
_containerClient = blobServiceClient.GetBlobContainerClient(containerName);
4343
_basePath = string.IsNullOrEmpty(basePath) ? string.Empty : basePath.TrimEnd('/') + '/';
44+
_createBlobWhenMissing = createBlobsWhenMissing;
4445
}
4546

4647
public async Task<BlobLeaseResult> TryAcquireAsync(string resourceName, TimeSpan leaseTime, CancellationToken cancellationToken)
@@ -54,7 +55,11 @@ public async Task<BlobLeaseResult> TryAcquireAsync(string resourceName, TimeSpan
5455
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.NotFound)
5556
{
5657
// The lease file does not exist. Try to create it and lease it.
57-
return await TryCreateAndAcquireAsync(blob, leaseTime, cancellationToken);
58+
if (_createBlobWhenMissing)
59+
{
60+
return await TryCreateAndAcquireAsync(blob, leaseTime, cancellationToken);
61+
}
62+
return BlobLeaseResult.Failure();
5863
}
5964
}
6065

@@ -65,7 +70,6 @@ public async Task<bool> ReleaseAsync(string resourceName, string leaseId, Cancel
6570
var blob = GetBlob(resourceName);
6671
var leaseClient = blob.GetBlobLeaseClient(leaseId);
6772
await leaseClient.ReleaseAsync(conditions: null, cancellationToken: cancellationToken);
68-
6973
return true;
7074
}
7175
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.Conflict)
@@ -94,6 +98,7 @@ public async Task<BlobLeaseResult> RenewAsync(string resourceName, string leaseI
9498
try
9599
{
96100
var lease = await leaseClient.RenewAsync(conditions: null, cancellationToken: cancellationToken);
101+
97102
return BlobLeaseResult.Success(lease);
98103
}
99104
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.Conflict || ex.Status == (int)HttpStatusCode.PreconditionFailed)
@@ -135,6 +140,7 @@ private async Task<BlobLeaseResult> TryAcquireAsync(BlobClient blob, TimeSpan le
135140
{
136141
var leaseClient = blob.GetBlobLeaseClient();
137142
var blobLease = await leaseClient.AcquireAsync(leaseTime, conditions: null, cancellationToken: cancellationToken);
143+
138144
return BlobLeaseResult.Success(blobLease);
139145
}
140146
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.Conflict)

src/NuGet.Services.Storage/NuGet.Services.Storage.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="Azure.Data.Tables" />
1011
<PackageReference Include="Azure.Identity" />
1112
<PackageReference Include="Azure.Storage.Blobs" />
1213
<PackageReference Include="Azure.Storage.Queues" />
1314
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
1415
<PackageReference Include="Newtonsoft.Json" />
16+
<PackageReference Include="System.Text.Json" />
1517
</ItemGroup>
1618

1719
</Project>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -9,14 +9,14 @@ namespace NuGet.Services.Validation.Issues
99
public sealed class UnauthorizedCertificateFailure : ValidationIssue
1010
{
1111
[JsonConstructor]
12-
public UnauthorizedCertificateFailure(string sha1Thumbprint)
12+
public UnauthorizedCertificateFailure(string sha256Thumbprint)
1313
{
14-
Sha1Thumbprint = sha1Thumbprint ?? throw new ArgumentNullException(nameof(sha1Thumbprint));
14+
Sha256Thumbprint = sha256Thumbprint ?? throw new ArgumentNullException(nameof(sha256Thumbprint));
1515
}
1616

1717
public override ValidationIssueCode IssueCode => ValidationIssueCode.PackageIsSignedWithUnauthorizedCertificate;
1818

1919
[JsonProperty("t", Required = Required.Always)]
20-
public string Sha1Thumbprint { get; }
20+
public string Sha256Thumbprint { get; }
2121
}
22-
}
22+
}

src/NuGet.Services.Validation/NuGet.Services.Validation.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<PackageReference Include="Azure.Core" />
1818
<PackageReference Include="EntityFramework" />
1919
<PackageReference Include="NuGet.Versioning" />
20+
<PackageReference Include="System.Text.Json" />
2021
</ItemGroup>
2122

2223
<ItemGroup>

0 commit comments

Comments
 (0)