|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Azure.Core;
using Azure.Storage.Blobs;
using Microsoft.Build.Utilities;
namespace Microsoft.DotNet.Build.Tasks.Feed
{
public class AzureStorageContainerAssetTokenCredentialPublisher : AzureStorageAssetPublisher
{
private readonly Uri _containerUri;
private readonly TokenCredential _tokenCredential;
public AzureStorageContainerAssetTokenCredentialPublisher(Uri containerUri, TokenCredential tokenCredential, TaskLoggingHelper log) : base(log)
{
_containerUri = containerUri;
_tokenCredential = tokenCredential;
}
public override BlobClient CreateBlobClient(string blobPath)
{
BlobClientOptions blobClientOptions = new BlobClientOptions();
blobClientOptions.Retry.Delay = TimeSpan.FromSeconds(5);
blobClientOptions.Retry.MaxDelay = TimeSpan.FromSeconds(30);
blobClientOptions.Retry.MaxRetries = 10;
blobClientOptions.Retry.Mode = RetryMode.Exponential;
blobClientOptions.Retry.NetworkTimeout = TimeSpan.FromSeconds(200);
var containerClient = new BlobContainerClient(_containerUri, _tokenCredential, blobClientOptions);
return containerClient.GetBlobClient(blobPath);
}
}
}
|