diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs index 6a36ca2fc946f..8aaa3c7e82651 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobClient.cs @@ -1629,8 +1629,6 @@ internal async Task> StagedUploadInternal( .ClientSideEncryptInternal(content, options.Metadata, async, cancellationToken).ConfigureAwait(false); } - var client = new BlockBlobClient(Uri, ClientConfiguration); - var uploader = GetPartitionedUploader( transferOptions: options?.TransferOptions ?? default, operationName: $"{nameof(BlobClient)}.{nameof(Upload)}"); @@ -1710,11 +1708,24 @@ internal async Task> StagedUploadInternal( } #endregion Upload + private BlockBlobClient _blockBlobClient; + + private BlockBlobClient BlockBlobClient + { + get + { + if (_blockBlobClient == null) + { + _blockBlobClient = new BlockBlobClient(Uri, ClientConfiguration); + } + return _blockBlobClient; + } + } + internal PartitionedUploader GetPartitionedUploader( StorageTransferOptions transferOptions, ArrayPool arrayPool = null, string operationName = null) - => new BlockBlobClient(Uri, ClientConfiguration) - .GetPartitionedUploader(transferOptions, arrayPool, operationName); + => BlockBlobClient.GetPartitionedUploader(transferOptions, arrayPool, operationName); } }