From 60d8468fffd566e11b13500a9e2ed737e4a073f7 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Thu, 13 Jul 2023 17:17:41 -0500 Subject: [PATCH 01/15] ClientConfigurations --- .../Azure.Storage.Blobs/src/BlobBaseClient.cs | 4 +- .../src/Shared/BlobClientConfiguration.cs | 42 +++++++++++++++++++ .../src/Shared/StorageClientConfiguration.cs | 30 +++++-------- .../src/DataLakeClientConfiguration.cs | 9 +++- .../src/ShareClientConfiguration.cs | 18 +++++--- .../src/QueueClientConfiguration.cs | 34 +++++++++++++++ 6 files changed, 107 insertions(+), 30 deletions(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index 94e5239b29ed4..9e8a5b2d58d85 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs @@ -651,9 +651,9 @@ protected static async Task GetCopyAuthorizationHeaderAsync( BlobBaseClient client, CancellationToken cancellationToken = default) { - if (client.ClientConfiguration.OAuthTokenCredential != default) + if (client.ClientConfiguration.TokenCredential != default) { - return await client.ClientConfiguration.OAuthTokenCredential.GetCopyAuthorizationHeaderAsync(cancellationToken).ConfigureAwait(false); + return await client.ClientConfiguration.TokenCredential.GetCopyAuthorizationHeaderAsync(cancellationToken).ConfigureAwait(false); } return default; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs index a145b396d7c8d..2c71a1ce489d3 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs @@ -71,10 +71,52 @@ public BlobClientConfiguration( TrimBlobNameSlashes = trimBlobNameSlashes; } + public BlobClientConfiguration( + HttpPipeline pipeline, + AzureSasCredential sasCredential, + ClientDiagnostics clientDiagnostics, + BlobClientOptions.ServiceVersion version, + CustomerProvidedKey? customerProvidedKey, + TransferValidationOptions transferValidation, + string encryptionScope, + bool trimBlobNameSlashes) + : base(pipeline, sasCredential, clientDiagnostics) + { + Version = version; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = transferValidation; + EncryptionScope = encryptionScope; + TrimBlobNameSlashes = trimBlobNameSlashes; + } + + private BlobClientConfiguration( + HttpPipeline pipeline, + StorageSharedKeyCredential sharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential, + ClientDiagnostics clientDiagnostics, + BlobClientOptions.ServiceVersion version, + CustomerProvidedKey? customerProvidedKey, + TransferValidationOptions transferValidation, + string encryptionScope, + bool trimBlobNameSlashes) + : base(pipeline, clientDiagnostics, sharedKeyCredential, sasCredential, tokenCredential) + { + Version = version; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = transferValidation; + EncryptionScope = encryptionScope; + TrimBlobNameSlashes = trimBlobNameSlashes; + } + + private BlobClientConfiguration() { } + internal static BlobClientConfiguration DeepCopy(BlobClientConfiguration originalClientConfiguration) => new BlobClientConfiguration( pipeline: originalClientConfiguration.Pipeline, sharedKeyCredential: originalClientConfiguration.SharedKeyCredential, + sasCredential: originalClientConfiguration.SasCredential, + tokenCredential: originalClientConfiguration.TokenCredential, clientDiagnostics: originalClientConfiguration.ClientDiagnostics, version: originalClientConfiguration.Version, customerProvidedKey: originalClientConfiguration.CustomerProvidedKey, diff --git a/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs b/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs index 9c1e21109dc72..b2e3bedc00de5 100644 --- a/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs @@ -16,7 +16,7 @@ internal class StorageClientConfiguration public virtual StorageSharedKeyCredential SharedKeyCredential { get; private set; } - public virtual TokenCredential OAuthTokenCredential { get; private set; } + public virtual TokenCredential TokenCredential { get; private set; } public virtual AzureSasCredential SasCredential { get; private set; } @@ -26,7 +26,7 @@ public StorageClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, ClientDiagnostics clientDiagnostics) - : this(pipeline, clientDiagnostics) + : this(pipeline, clientDiagnostics, sharedKeyCredential, null, null) { SharedKeyCredential = sharedKeyCredential; } @@ -35,45 +35,35 @@ public StorageClientConfiguration( HttpPipeline pipeline, AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics) - : this (pipeline, clientDiagnostics) + : this (pipeline, clientDiagnostics, null, sasCredential, null) { - SasCredential = sasCredential; } public StorageClientConfiguration( HttpPipeline pipeline, TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics) - : this(pipeline, clientDiagnostics) + : this (pipeline, clientDiagnostics, null, null, tokenCredential) { - OAuthTokenCredential = tokenCredential; } - internal StorageClientConfiguration( + protected StorageClientConfiguration( HttpPipeline pipeline, + ClientDiagnostics clientDiagnostics, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, - TokenCredential tokenCredential, - ClientDiagnostics clientDiagnostics) + TokenCredential tokenCredential) { Pipeline = pipeline; + ClientDiagnostics = clientDiagnostics; SharedKeyCredential = sharedKeyCredential; SasCredential = sasCredential; - OAuthTokenCredential = tokenCredential; - ClientDiagnostics = clientDiagnostics; - } - - internal StorageClientConfiguration( - HttpPipeline pipeline, - ClientDiagnostics clientDiagnostics) - { - Pipeline = pipeline; - ClientDiagnostics = clientDiagnostics; + TokenCredential = tokenCredential; } /// /// Constructor for mocking. /// - internal StorageClientConfiguration() { } + protected StorageClientConfiguration() { } } } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs index 7dddb730bc205..98cc427e31849 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.Core; using Azure.Core.Pipeline; using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Shared; @@ -41,25 +42,29 @@ public DataLakeClientConfiguration( TransferValidation = clientOptions.TransferValidation; } - internal DataLakeClientConfiguration( + private DataLakeClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, + TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics, DataLakeClientOptions clientOptions, DataLakeCustomerProvidedKey? customerProvidedKey) - : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) + : base(pipeline, clientDiagnostics, sharedKeyCredential, sasCredential, tokenCredential) { ClientOptions = clientOptions; CustomerProvidedKey = customerProvidedKey; TransferValidation = clientOptions.TransferValidation; } + private DataLakeClientConfiguration() { } + internal static DataLakeClientConfiguration DeepCopy(DataLakeClientConfiguration originalClientConfiguration) => new DataLakeClientConfiguration( pipeline: originalClientConfiguration.Pipeline, sharedKeyCredential: originalClientConfiguration.SharedKeyCredential, sasCredential: originalClientConfiguration.SasCredential, + tokenCredential: originalClientConfiguration.TokenCredential, clientDiagnostics: originalClientConfiguration.ClientDiagnostics, clientOptions: originalClientConfiguration.ClientOptions, customerProvidedKey: originalClientConfiguration.CustomerProvidedKey); diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs index baadc154fc7dd..18761e9b6029d 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.Core; using Azure.Core.Pipeline; using Azure.Storage.Files.Shares.Models; using Azure.Storage.Shared; @@ -18,8 +19,10 @@ public ShareClientConfiguration( StorageSharedKeyCredential sharedKeyCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : this(pipeline, sharedKeyCredential, default, clientDiagnostics, clientOptions) + : base(pipeline, sharedKeyCredential, clientDiagnostics) { + ClientOptions = clientOptions; + TransferValidation = clientOptions.TransferValidation; } public ShareClientConfiguration( @@ -27,20 +30,23 @@ public ShareClientConfiguration( AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : this(pipeline, default, sasCredential, clientDiagnostics, clientOptions) + : base(pipeline, sasCredential, clientDiagnostics) { + ClientOptions = clientOptions; + TransferValidation = clientOptions.TransferValidation; } - internal ShareClientConfiguration( + public ShareClientConfiguration( HttpPipeline pipeline, - StorageSharedKeyCredential sharedKeyCredential, - AzureSasCredential sasCredential, + TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) + : base(pipeline, tokenCredential, clientDiagnostics) { ClientOptions = clientOptions; TransferValidation = clientOptions.TransferValidation; } + + private ShareClientConfiguration() { } } } diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs index cacb5e99d12e8..8d19c62cd1cec 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs @@ -33,5 +33,39 @@ public QueueClientConfiguration( MessageEncoding = messageEncoding; QueueMessageDecodingFailedHandlers = queueMessageDecodingFailedHandlers; } + + public QueueClientConfiguration( + HttpPipeline pipeline, + AzureSasCredential sasCredential, + ClientDiagnostics clientDiagnostics, + QueueClientOptions.ServiceVersion version, + QueueClientSideEncryptionOptions clientSideEncryption, + QueueMessageEncoding messageEncoding, + SyncAsyncEventHandler queueMessageDecodingFailedHandlers) + : base(pipeline, sasCredential, clientDiagnostics) + { + Version = version; + ClientSideEncryption = clientSideEncryption; + MessageEncoding = messageEncoding; + QueueMessageDecodingFailedHandlers = queueMessageDecodingFailedHandlers; + } + + public QueueClientConfiguration( + HttpPipeline pipeline, + TokenCredential tokenCredential, + ClientDiagnostics clientDiagnostics, + QueueClientOptions.ServiceVersion version, + QueueClientSideEncryptionOptions clientSideEncryption, + QueueMessageEncoding messageEncoding, + SyncAsyncEventHandler queueMessageDecodingFailedHandlers) + : base(pipeline, tokenCredential, clientDiagnostics) + { + Version = version; + ClientSideEncryption = clientSideEncryption; + MessageEncoding = messageEncoding; + QueueMessageDecodingFailedHandlers = queueMessageDecodingFailedHandlers; + } + + private QueueClientConfiguration() { } } } From 359947b5e3ba7b2f24dda11db18801a791d4899d Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Thu, 13 Jul 2023 17:24:56 -0500 Subject: [PATCH 02/15] Revert "ClientConfigurations" This reverts commit 60d8468fffd566e11b13500a9e2ed737e4a073f7. --- .../Azure.Storage.Blobs/src/BlobBaseClient.cs | 4 +- .../src/Shared/BlobClientConfiguration.cs | 42 ------------------- .../src/Shared/StorageClientConfiguration.cs | 30 ++++++++----- .../src/DataLakeClientConfiguration.cs | 9 +--- .../src/ShareClientConfiguration.cs | 18 +++----- .../src/QueueClientConfiguration.cs | 34 --------------- 6 files changed, 30 insertions(+), 107 deletions(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index 9e8a5b2d58d85..94e5239b29ed4 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs @@ -651,9 +651,9 @@ protected static async Task GetCopyAuthorizationHeaderAsync( BlobBaseClient client, CancellationToken cancellationToken = default) { - if (client.ClientConfiguration.TokenCredential != default) + if (client.ClientConfiguration.OAuthTokenCredential != default) { - return await client.ClientConfiguration.TokenCredential.GetCopyAuthorizationHeaderAsync(cancellationToken).ConfigureAwait(false); + return await client.ClientConfiguration.OAuthTokenCredential.GetCopyAuthorizationHeaderAsync(cancellationToken).ConfigureAwait(false); } return default; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs index 2c71a1ce489d3..a145b396d7c8d 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs @@ -71,52 +71,10 @@ public BlobClientConfiguration( TrimBlobNameSlashes = trimBlobNameSlashes; } - public BlobClientConfiguration( - HttpPipeline pipeline, - AzureSasCredential sasCredential, - ClientDiagnostics clientDiagnostics, - BlobClientOptions.ServiceVersion version, - CustomerProvidedKey? customerProvidedKey, - TransferValidationOptions transferValidation, - string encryptionScope, - bool trimBlobNameSlashes) - : base(pipeline, sasCredential, clientDiagnostics) - { - Version = version; - CustomerProvidedKey = customerProvidedKey; - TransferValidation = transferValidation; - EncryptionScope = encryptionScope; - TrimBlobNameSlashes = trimBlobNameSlashes; - } - - private BlobClientConfiguration( - HttpPipeline pipeline, - StorageSharedKeyCredential sharedKeyCredential, - AzureSasCredential sasCredential, - TokenCredential tokenCredential, - ClientDiagnostics clientDiagnostics, - BlobClientOptions.ServiceVersion version, - CustomerProvidedKey? customerProvidedKey, - TransferValidationOptions transferValidation, - string encryptionScope, - bool trimBlobNameSlashes) - : base(pipeline, clientDiagnostics, sharedKeyCredential, sasCredential, tokenCredential) - { - Version = version; - CustomerProvidedKey = customerProvidedKey; - TransferValidation = transferValidation; - EncryptionScope = encryptionScope; - TrimBlobNameSlashes = trimBlobNameSlashes; - } - - private BlobClientConfiguration() { } - internal static BlobClientConfiguration DeepCopy(BlobClientConfiguration originalClientConfiguration) => new BlobClientConfiguration( pipeline: originalClientConfiguration.Pipeline, sharedKeyCredential: originalClientConfiguration.SharedKeyCredential, - sasCredential: originalClientConfiguration.SasCredential, - tokenCredential: originalClientConfiguration.TokenCredential, clientDiagnostics: originalClientConfiguration.ClientDiagnostics, version: originalClientConfiguration.Version, customerProvidedKey: originalClientConfiguration.CustomerProvidedKey, diff --git a/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs b/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs index b2e3bedc00de5..9c1e21109dc72 100644 --- a/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs @@ -16,7 +16,7 @@ internal class StorageClientConfiguration public virtual StorageSharedKeyCredential SharedKeyCredential { get; private set; } - public virtual TokenCredential TokenCredential { get; private set; } + public virtual TokenCredential OAuthTokenCredential { get; private set; } public virtual AzureSasCredential SasCredential { get; private set; } @@ -26,7 +26,7 @@ public StorageClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, ClientDiagnostics clientDiagnostics) - : this(pipeline, clientDiagnostics, sharedKeyCredential, null, null) + : this(pipeline, clientDiagnostics) { SharedKeyCredential = sharedKeyCredential; } @@ -35,35 +35,45 @@ public StorageClientConfiguration( HttpPipeline pipeline, AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics) - : this (pipeline, clientDiagnostics, null, sasCredential, null) + : this (pipeline, clientDiagnostics) { + SasCredential = sasCredential; } public StorageClientConfiguration( HttpPipeline pipeline, TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics) - : this (pipeline, clientDiagnostics, null, null, tokenCredential) + : this(pipeline, clientDiagnostics) { + OAuthTokenCredential = tokenCredential; } - protected StorageClientConfiguration( + internal StorageClientConfiguration( HttpPipeline pipeline, - ClientDiagnostics clientDiagnostics, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, - TokenCredential tokenCredential) + TokenCredential tokenCredential, + ClientDiagnostics clientDiagnostics) { Pipeline = pipeline; - ClientDiagnostics = clientDiagnostics; SharedKeyCredential = sharedKeyCredential; SasCredential = sasCredential; - TokenCredential = tokenCredential; + OAuthTokenCredential = tokenCredential; + ClientDiagnostics = clientDiagnostics; + } + + internal StorageClientConfiguration( + HttpPipeline pipeline, + ClientDiagnostics clientDiagnostics) + { + Pipeline = pipeline; + ClientDiagnostics = clientDiagnostics; } /// /// Constructor for mocking. /// - protected StorageClientConfiguration() { } + internal StorageClientConfiguration() { } } } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs index 98cc427e31849..7dddb730bc205 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.Core; using Azure.Core.Pipeline; using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Shared; @@ -42,29 +41,25 @@ public DataLakeClientConfiguration( TransferValidation = clientOptions.TransferValidation; } - private DataLakeClientConfiguration( + internal DataLakeClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, - TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics, DataLakeClientOptions clientOptions, DataLakeCustomerProvidedKey? customerProvidedKey) - : base(pipeline, clientDiagnostics, sharedKeyCredential, sasCredential, tokenCredential) + : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) { ClientOptions = clientOptions; CustomerProvidedKey = customerProvidedKey; TransferValidation = clientOptions.TransferValidation; } - private DataLakeClientConfiguration() { } - internal static DataLakeClientConfiguration DeepCopy(DataLakeClientConfiguration originalClientConfiguration) => new DataLakeClientConfiguration( pipeline: originalClientConfiguration.Pipeline, sharedKeyCredential: originalClientConfiguration.SharedKeyCredential, sasCredential: originalClientConfiguration.SasCredential, - tokenCredential: originalClientConfiguration.TokenCredential, clientDiagnostics: originalClientConfiguration.ClientDiagnostics, clientOptions: originalClientConfiguration.ClientOptions, customerProvidedKey: originalClientConfiguration.CustomerProvidedKey); diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs index 18761e9b6029d..baadc154fc7dd 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.Core; using Azure.Core.Pipeline; using Azure.Storage.Files.Shares.Models; using Azure.Storage.Shared; @@ -19,10 +18,8 @@ public ShareClientConfiguration( StorageSharedKeyCredential sharedKeyCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : base(pipeline, sharedKeyCredential, clientDiagnostics) + : this(pipeline, sharedKeyCredential, default, clientDiagnostics, clientOptions) { - ClientOptions = clientOptions; - TransferValidation = clientOptions.TransferValidation; } public ShareClientConfiguration( @@ -30,23 +27,20 @@ public ShareClientConfiguration( AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : base(pipeline, sasCredential, clientDiagnostics) + : this(pipeline, default, sasCredential, clientDiagnostics, clientOptions) { - ClientOptions = clientOptions; - TransferValidation = clientOptions.TransferValidation; } - public ShareClientConfiguration( + internal ShareClientConfiguration( HttpPipeline pipeline, - TokenCredential tokenCredential, + StorageSharedKeyCredential sharedKeyCredential, + AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : base(pipeline, tokenCredential, clientDiagnostics) + : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) { ClientOptions = clientOptions; TransferValidation = clientOptions.TransferValidation; } - - private ShareClientConfiguration() { } } } diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs index 8d19c62cd1cec..cacb5e99d12e8 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs @@ -33,39 +33,5 @@ public QueueClientConfiguration( MessageEncoding = messageEncoding; QueueMessageDecodingFailedHandlers = queueMessageDecodingFailedHandlers; } - - public QueueClientConfiguration( - HttpPipeline pipeline, - AzureSasCredential sasCredential, - ClientDiagnostics clientDiagnostics, - QueueClientOptions.ServiceVersion version, - QueueClientSideEncryptionOptions clientSideEncryption, - QueueMessageEncoding messageEncoding, - SyncAsyncEventHandler queueMessageDecodingFailedHandlers) - : base(pipeline, sasCredential, clientDiagnostics) - { - Version = version; - ClientSideEncryption = clientSideEncryption; - MessageEncoding = messageEncoding; - QueueMessageDecodingFailedHandlers = queueMessageDecodingFailedHandlers; - } - - public QueueClientConfiguration( - HttpPipeline pipeline, - TokenCredential tokenCredential, - ClientDiagnostics clientDiagnostics, - QueueClientOptions.ServiceVersion version, - QueueClientSideEncryptionOptions clientSideEncryption, - QueueMessageEncoding messageEncoding, - SyncAsyncEventHandler queueMessageDecodingFailedHandlers) - : base(pipeline, tokenCredential, clientDiagnostics) - { - Version = version; - ClientSideEncryption = clientSideEncryption; - MessageEncoding = messageEncoding; - QueueMessageDecodingFailedHandlers = queueMessageDecodingFailedHandlers; - } - - private QueueClientConfiguration() { } } } From 25545da32fe040661e2147c3b969563f48039e25 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 12:09:42 -0500 Subject: [PATCH 03/15] ClientConfigurations --- .../Azure.Storage.Blobs/src/BlobBaseClient.cs | 4 +- .../src/Shared/BlobClientConfiguration.cs | 72 +++++++++++++++++++ .../src/Shared/StorageClientConfiguration.cs | 22 +++++- .../src/DataLakeClientConfiguration.cs | 45 +++++++++++- .../src/ShareClientConfiguration.cs | 40 +++++++++-- .../src/QueueClientConfiguration.cs | 72 ++++++++++++++++++- 6 files changed, 243 insertions(+), 12 deletions(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index 94e5239b29ed4..9e8a5b2d58d85 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs @@ -651,9 +651,9 @@ protected static async Task GetCopyAuthorizationHeaderAsync( BlobBaseClient client, CancellationToken cancellationToken = default) { - if (client.ClientConfiguration.OAuthTokenCredential != default) + if (client.ClientConfiguration.TokenCredential != default) { - return await client.ClientConfiguration.OAuthTokenCredential.GetCopyAuthorizationHeaderAsync(cancellationToken).ConfigureAwait(false); + return await client.ClientConfiguration.TokenCredential.GetCopyAuthorizationHeaderAsync(cancellationToken).ConfigureAwait(false); } return default; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs index a145b396d7c8d..f307d54ac4c0e 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs @@ -35,6 +35,10 @@ internal class BlobClientConfiguration : StorageClientConfiguration public bool TrimBlobNameSlashes { get; internal set; } + /// + /// Create a with token authentication. + /// + public BlobClientConfiguration( HttpPipeline pipeline, TokenCredential tokenCredential, @@ -53,6 +57,9 @@ public BlobClientConfiguration( TrimBlobNameSlashes = trimBlobNameSlashes; } + /// + /// Create a with shared key authentication. + /// public BlobClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, @@ -71,10 +78,75 @@ public BlobClientConfiguration( TrimBlobNameSlashes = trimBlobNameSlashes; } + /// + /// Create a with SAS authentication. + /// + public BlobClientConfiguration( + HttpPipeline pipeline, + AzureSasCredential azureSasCredential, + ClientDiagnostics clientDiagnostics, + BlobClientOptions.ServiceVersion version, + CustomerProvidedKey? customerProvidedKey, + TransferValidationOptions transferValidation, + string encryptionScope, + bool trimBlobNameSlashes) + : base(pipeline, azureSasCredential, clientDiagnostics) + { + Version = version; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = transferValidation; + EncryptionScope = encryptionScope; + TrimBlobNameSlashes = trimBlobNameSlashes; + } + + /// + /// Create a without authentication, + /// or with SAS that was provided as part of the URL. + /// + + public BlobClientConfiguration( + HttpPipeline pipeline, + ClientDiagnostics clientDiagnostics, + BlobClientOptions.ServiceVersion version, + CustomerProvidedKey? customerProvidedKey, + TransferValidationOptions transferValidation, + string encryptionScope, + bool trimBlobNameSlashes) + : base(pipeline, clientDiagnostics) + { + Version = version; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = transferValidation; + EncryptionScope = encryptionScope; + TrimBlobNameSlashes = trimBlobNameSlashes; + } + + private BlobClientConfiguration( + HttpPipeline pipeline, + StorageSharedKeyCredential sharedKeyCredential, + TokenCredential tokenCredential, + AzureSasCredential sasCredential, + ClientDiagnostics clientDiagnostics, + BlobClientOptions.ServiceVersion version, + CustomerProvidedKey? customerProvidedKey, + TransferValidationOptions transferValidation, + string encryptionScope, + bool trimBlobNameSlashes) + : base(pipeline, sharedKeyCredential, sasCredential, tokenCredential, clientDiagnostics) + { + Version = version; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = transferValidation; + EncryptionScope = encryptionScope; + TrimBlobNameSlashes = trimBlobNameSlashes; + } + internal static BlobClientConfiguration DeepCopy(BlobClientConfiguration originalClientConfiguration) => new BlobClientConfiguration( pipeline: originalClientConfiguration.Pipeline, sharedKeyCredential: originalClientConfiguration.SharedKeyCredential, + tokenCredential: originalClientConfiguration.TokenCredential, + sasCredential: originalClientConfiguration.SasCredential, clientDiagnostics: originalClientConfiguration.ClientDiagnostics, version: originalClientConfiguration.Version, customerProvidedKey: originalClientConfiguration.CustomerProvidedKey, diff --git a/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs b/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs index 9c1e21109dc72..4274111c7fd33 100644 --- a/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Common/src/Shared/StorageClientConfiguration.cs @@ -16,12 +16,15 @@ internal class StorageClientConfiguration public virtual StorageSharedKeyCredential SharedKeyCredential { get; private set; } - public virtual TokenCredential OAuthTokenCredential { get; private set; } + public virtual TokenCredential TokenCredential { get; private set; } public virtual AzureSasCredential SasCredential { get; private set; } public virtual ClientDiagnostics ClientDiagnostics { get; private set; } + /// + /// Create a with shared key authentication. + /// public StorageClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, @@ -31,6 +34,9 @@ public StorageClientConfiguration( SharedKeyCredential = sharedKeyCredential; } + /// + /// Create a with SAS authentication. + /// public StorageClientConfiguration( HttpPipeline pipeline, AzureSasCredential sasCredential, @@ -40,15 +46,21 @@ public StorageClientConfiguration( SasCredential = sasCredential; } + /// + /// Create a with token authentication. + /// public StorageClientConfiguration( HttpPipeline pipeline, TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics) : this(pipeline, clientDiagnostics) { - OAuthTokenCredential = tokenCredential; + TokenCredential = tokenCredential; } + /// + /// Only use for creating a deep copy of a . + /// internal StorageClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, @@ -59,10 +71,14 @@ internal StorageClientConfiguration( Pipeline = pipeline; SharedKeyCredential = sharedKeyCredential; SasCredential = sasCredential; - OAuthTokenCredential = tokenCredential; + TokenCredential = tokenCredential; ClientDiagnostics = clientDiagnostics; } + /// + /// Create a without authentication, + /// or with SAS that was provided as part of the URL. + /// internal StorageClientConfiguration( HttpPipeline pipeline, ClientDiagnostics clientDiagnostics) diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs index 7dddb730bc205..50bbcc7740145 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.Core; using Azure.Core.Pipeline; using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Shared; @@ -15,6 +16,25 @@ internal class DataLakeClientConfiguration : StorageClientConfiguration public virtual TransferValidationOptions TransferValidation { get; } = new(); + /// + /// Create a without authentication, + /// or with SAS that was provided as part of the URL. + /// + public DataLakeClientConfiguration( + HttpPipeline pipeline, + ClientDiagnostics clientDiagnostics, + DataLakeClientOptions clientOptions, + DataLakeCustomerProvidedKey? customerProvidedKey) + : base(pipeline, clientDiagnostics) + { + ClientOptions = clientOptions; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = clientOptions.TransferValidation; + } + + /// + /// Create a with shared key authentication. + /// public DataLakeClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, @@ -28,6 +48,9 @@ public DataLakeClientConfiguration( TransferValidation = clientOptions.TransferValidation; } + /// + /// Create a with SAS authentication. + /// public DataLakeClientConfiguration( HttpPipeline pipeline, AzureSasCredential sasCredential, @@ -41,14 +64,31 @@ public DataLakeClientConfiguration( TransferValidation = clientOptions.TransferValidation; } - internal DataLakeClientConfiguration( + /// + /// Create a with token authentication. + /// + public DataLakeClientConfiguration( + HttpPipeline pipeline, + TokenCredential tokenCredential, + ClientDiagnostics clientDiagnostics, + DataLakeClientOptions clientOptions, + DataLakeCustomerProvidedKey? customerProvidedKey) + : base(pipeline, tokenCredential, clientDiagnostics) + { + ClientOptions = clientOptions; + CustomerProvidedKey = customerProvidedKey; + TransferValidation = clientOptions.TransferValidation; + } + + private DataLakeClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, + TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics, DataLakeClientOptions clientOptions, DataLakeCustomerProvidedKey? customerProvidedKey) - : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) + : base(pipeline, sharedKeyCredential, sasCredential, tokenCredential, clientDiagnostics) { ClientOptions = clientOptions; CustomerProvidedKey = customerProvidedKey; @@ -60,6 +100,7 @@ internal static DataLakeClientConfiguration DeepCopy(DataLakeClientConfiguration pipeline: originalClientConfiguration.Pipeline, sharedKeyCredential: originalClientConfiguration.SharedKeyCredential, sasCredential: originalClientConfiguration.SasCredential, + tokenCredential: originalClientConfiguration.TokenCredential, clientDiagnostics: originalClientConfiguration.ClientDiagnostics, clientOptions: originalClientConfiguration.ClientOptions, customerProvidedKey: originalClientConfiguration.CustomerProvidedKey); diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs index baadc154fc7dd..16dfcd55ab2c8 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.Core; using Azure.Core.Pipeline; using Azure.Storage.Files.Shares.Models; using Azure.Storage.Shared; @@ -13,31 +14,62 @@ internal class ShareClientConfiguration : StorageClientConfiguration public TransferValidationOptions TransferValidation { get; internal set; } + /// + /// Create a with shared key authentication. + /// public ShareClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : this(pipeline, sharedKeyCredential, default, clientDiagnostics, clientOptions) + : this(pipeline, sharedKeyCredential, default, default, clientDiagnostics, clientOptions) { } + /// + /// Create a with SAS authentication. + /// public ShareClientConfiguration( HttpPipeline pipeline, AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : this(pipeline, default, sasCredential, clientDiagnostics, clientOptions) + : this(pipeline, default, sasCredential, default, clientDiagnostics, clientOptions) { } - internal ShareClientConfiguration( + /// + /// Create a with token authentication. + /// + public ShareClientConfiguration( + HttpPipeline pipeline, + TokenCredential tokenCredential, + ClientDiagnostics clientDiagnostics, + ShareClientOptions clientOptions) + : this(pipeline, default, default, tokenCredential, clientDiagnostics, clientOptions) + { + } + + /// + /// Create a without authentication, + /// or with SAS that was provided as part of the URL. + /// + public ShareClientConfiguration( + HttpPipeline pipeline, + ClientDiagnostics clientDiagnostics, + ShareClientOptions clientOptions) + : this(pipeline, default, default, default, clientDiagnostics, clientOptions) + { + } + + private ShareClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, + TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics, ShareClientOptions clientOptions) - : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) + : base(pipeline, sharedKeyCredential, sasCredential, tokenCredential, clientDiagnostics) { ClientOptions = clientOptions; TransferValidation = clientOptions.TransferValidation; diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs index cacb5e99d12e8..6a46fff5e9375 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs @@ -18,6 +18,9 @@ internal class QueueClientConfiguration : StorageClientConfiguration public SyncAsyncEventHandler QueueMessageDecodingFailedHandlers { get; internal set; } + /// + /// Create a with shared key authentication. + /// public QueueClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, @@ -26,7 +29,74 @@ public QueueClientConfiguration( QueueClientSideEncryptionOptions clientSideEncryption, QueueMessageEncoding messageEncoding, SyncAsyncEventHandler queueMessageDecodingFailedHandlers) - : base(pipeline, sharedKeyCredential, clientDiagnostics) + : this( + pipeline, + sharedKeyCredential, + default, + clientDiagnostics, + version, + clientSideEncryption, + messageEncoding, + queueMessageDecodingFailedHandlers) + { + } + + /// + /// Create a with SAS authentication. + /// + public QueueClientConfiguration( + HttpPipeline pipeline, + AzureSasCredential sasCredential, + ClientDiagnostics clientDiagnostics, + QueueClientOptions.ServiceVersion version, + QueueClientSideEncryptionOptions clientSideEncryption, + QueueMessageEncoding messageEncoding, + SyncAsyncEventHandler queueMessageDecodingFailedHandlers) + : this( + pipeline, + default, + sasCredential, + clientDiagnostics, + version, + clientSideEncryption, + messageEncoding, + queueMessageDecodingFailedHandlers) + { + } + + /// + /// Create a without authentication, + /// or with SAS that was provided as part of the URL. + /// + public QueueClientConfiguration( + HttpPipeline pipeline, + ClientDiagnostics clientDiagnostics, + QueueClientOptions.ServiceVersion version, + QueueClientSideEncryptionOptions clientSideEncryption, + QueueMessageEncoding messageEncoding, + SyncAsyncEventHandler queueMessageDecodingFailedHandlers) + : this( + pipeline, + default, + default, + clientDiagnostics, + version, + clientSideEncryption, + messageEncoding, + queueMessageDecodingFailedHandlers) + { + } + + private QueueClientConfiguration( + HttpPipeline pipeline, + StorageSharedKeyCredential sharedKeyCredential, + AzureSasCredential sasCredential, + ClientDiagnostics clientDiagnostics, + QueueClientOptions.ServiceVersion version, + QueueClientSideEncryptionOptions clientSideEncryption, + QueueMessageEncoding messageEncoding, + SyncAsyncEventHandler queueMessageDecodingFailedHandlers) + : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) { Version = version; ClientSideEncryption = clientSideEncryption; From 932cb5be86a3c17b648f5bf4936dfdd4fb92c5f8 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 12:48:21 -0500 Subject: [PATCH 04/15] Queues --- .../Azure.Storage.Queues/src/QueueClient.cs | 44 +++++++++++++++-- .../src/QueueClientConfiguration.cs | 35 +++++++++++++- .../src/QueueServiceClient.cs | 48 ++++++++++++++++--- 3 files changed, 113 insertions(+), 14 deletions(-) diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs index 9f12a0f268f37..d4c82729552ae 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs @@ -234,7 +234,13 @@ public QueueClient(string connectionString, string queueName, QueueClientOptions /// /// Storage SAS Token Overview public QueueClient(Uri queueUri, QueueClientOptions options = default) - : this(queueUri, (HttpPipelinePolicy)null, options, null) + : this( + queueUri, + (HttpPipelinePolicy)null, + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -256,7 +262,13 @@ public QueueClient(Uri queueUri, QueueClientOptions options = default) /// every request. /// public QueueClient(Uri queueUri, StorageSharedKeyCredential credential, QueueClientOptions options = default) - : this(queueUri, credential.AsPolicy(), options, credential) + : this( + queueUri, + credential.AsPolicy(), + options, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -282,7 +294,13 @@ public QueueClient(Uri queueUri, StorageSharedKeyCredential credential, QueueCli /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public QueueClient(Uri queueUri, AzureSasCredential credential, QueueClientOptions options = default) - : this(queueUri, credential.AsPolicy(queueUri), options, null) + : this( + queueUri, + credential.AsPolicy(queueUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -304,7 +322,13 @@ public QueueClient(Uri queueUri, AzureSasCredential credential, QueueClientOptio /// every request. /// public QueueClient(Uri queueUri, TokenCredential credential, QueueClientOptions options = default) - : this(queueUri, credential.AsPolicy(options), options, null) + : this( + queueUri, + credential.AsPolicy(options), + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(queueUri); } @@ -329,11 +353,19 @@ public QueueClient(Uri queueUri, TokenCredential credential, QueueClientOptions /// /// The shared key credential used to sign requests. /// + /// + /// The token credential used to sign requests. + /// + /// + /// The SAS credential used to sign requests. + /// internal QueueClient( Uri queueUri, HttpPipelinePolicy authentication, QueueClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(queueUri, nameof(queueUri)); _uri = queueUri; @@ -342,6 +374,8 @@ internal QueueClient( _clientConfiguration = new QueueClientConfiguration( pipeline: options.Build(authentication), sharedKeyCredential: storageSharedKeyCredential, + sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), version: options.Version, clientSideEncryption: QueueClientSideEncryptionOptions.CloneFrom(options._clientSideEncryptionOptions), diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs index 6a46fff5e9375..8be13423203a5 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClientConfiguration.cs @@ -33,6 +33,7 @@ public QueueClientConfiguration( pipeline, sharedKeyCredential, default, + default, clientDiagnostics, version, clientSideEncryption, @@ -56,6 +57,31 @@ public QueueClientConfiguration( pipeline, default, sasCredential, + default, + clientDiagnostics, + version, + clientSideEncryption, + messageEncoding, + queueMessageDecodingFailedHandlers) + { + } + + /// + /// Create a with SAS authentication. + /// + public QueueClientConfiguration( + HttpPipeline pipeline, + TokenCredential tokenCredential, + ClientDiagnostics clientDiagnostics, + QueueClientOptions.ServiceVersion version, + QueueClientSideEncryptionOptions clientSideEncryption, + QueueMessageEncoding messageEncoding, + SyncAsyncEventHandler queueMessageDecodingFailedHandlers) + : this( + pipeline, + default, + default, + tokenCredential, clientDiagnostics, version, clientSideEncryption, @@ -79,6 +105,7 @@ public QueueClientConfiguration( pipeline, default, default, + default, clientDiagnostics, version, clientSideEncryption, @@ -87,16 +114,20 @@ public QueueClientConfiguration( { } - private QueueClientConfiguration( + /// + /// Used for internal Client Constructors that accept multiple types of authentication. + /// + internal QueueClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, + TokenCredential tokenCredential, ClientDiagnostics clientDiagnostics, QueueClientOptions.ServiceVersion version, QueueClientSideEncryptionOptions clientSideEncryption, QueueMessageEncoding messageEncoding, SyncAsyncEventHandler queueMessageDecodingFailedHandlers) - : base(pipeline, sharedKeyCredential, sasCredential, default, clientDiagnostics) + : base(pipeline, sharedKeyCredential, sasCredential, tokenCredential, clientDiagnostics) { Version = version; ClientSideEncryption = clientSideEncryption; diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs index 774988834289d..73a5ad529eef6 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs @@ -153,7 +153,13 @@ public QueueServiceClient(string connectionString, QueueClientOptions options) /// /// Storage SAS Token Overview public QueueServiceClient(Uri serviceUri, QueueClientOptions options = default) - : this(serviceUri, (HttpPipelinePolicy)null, options, null) + : this( + serviceUri, + (HttpPipelinePolicy)null, + options, + sharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -174,7 +180,13 @@ public QueueServiceClient(Uri serviceUri, QueueClientOptions options = default) /// every request. /// public QueueServiceClient(Uri serviceUri, StorageSharedKeyCredential credential, QueueClientOptions options = default) - : this(serviceUri, credential.AsPolicy(), options, credential) + : this( + serviceUri, + credential.AsPolicy(), + options, + credential, + sasCredential: null, + tokenCredential: null) { } @@ -199,7 +211,13 @@ public QueueServiceClient(Uri serviceUri, StorageSharedKeyCredential credential, /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public QueueServiceClient(Uri serviceUri, AzureSasCredential credential, QueueClientOptions options = default) - : this(serviceUri, credential.AsPolicy(serviceUri), options, null) + : this( + serviceUri, + credential.AsPolicy(serviceUri), + options, + sharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -220,7 +238,13 @@ public QueueServiceClient(Uri serviceUri, AzureSasCredential credential, QueueCl /// every request. /// public QueueServiceClient(Uri serviceUri, TokenCredential credential, QueueClientOptions options = default) - : this(serviceUri, credential.AsPolicy(options), options, null) + : this( + serviceUri, + credential.AsPolicy(options), + options, + sharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(serviceUri); } @@ -241,14 +265,22 @@ public QueueServiceClient(Uri serviceUri, TokenCredential credential, QueueClien /// policies for authentication, retries, etc., that are applied to /// every request. /// - /// + /// /// The shared key credential used to sign requests. /// + /// + /// The token credential used to sign requests. + /// + /// + /// The SAS credential used to sign requests. + /// internal QueueServiceClient( Uri serviceUri, HttpPipelinePolicy authentication, QueueClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) + StorageSharedKeyCredential sharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(serviceUri, nameof(serviceUri)); _uri = serviceUri; @@ -256,7 +288,9 @@ internal QueueServiceClient( _clientConfiguration = new QueueClientConfiguration( pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, + sharedKeyCredential: sharedKeyCredential, + sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), version: options.Version, clientSideEncryption: QueueClientSideEncryptionOptions.CloneFrom(options._clientSideEncryptionOptions), From c9040e2565f48b11c4a3150bd6d7f50228783705 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 13:02:16 -0500 Subject: [PATCH 05/15] Shares --- .../src/ShareClient.cs | 73 ++++++------ .../src/ShareClientConfiguration.cs | 5 +- .../src/ShareDirectoryClient.cs | 107 +++++------------- .../src/ShareFileClient.cs | 107 +++++------------- .../src/ShareServiceClient.cs | 76 ++++++------- .../Azure.Storage.Queues/src/QueueClient.cs | 6 +- 6 files changed, 127 insertions(+), 247 deletions(-) diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs index d5341abd516c5..b9603c3758ba3 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs @@ -182,7 +182,13 @@ public ShareClient( public ShareClient( Uri shareUri, ShareClientOptions options = default) - : this(shareUri, (HttpPipelinePolicy)null, options, sasCredential: null) + : this( + shareUri, + (HttpPipelinePolicy)null, + options, + storageSharedKeyCredential: default, + sasCredential: default, + tokenCredential: default) { } @@ -206,7 +212,13 @@ public ShareClient( Uri shareUri, StorageSharedKeyCredential credential, ShareClientOptions options = default) - : this(shareUri, credential.AsPolicy(), options, credential) + : this( + shareUri, + credential.AsPolicy(), + options, + storageSharedKeyCredential: credential, + sasCredential: default, + tokenCredential: default) { } @@ -238,7 +250,13 @@ public ShareClient( Uri shareUri, AzureSasCredential credential, ShareClientOptions options = default) - : this(shareUri, credential.AsPolicy(shareUri), options, sasCredential: credential) + : this( + shareUri, + credential.AsPolicy(shareUri), + options, + storageSharedKeyCredential: default, + sasCredential: credential, + tokenCredential: default) { } @@ -277,7 +295,9 @@ public ShareClient( shareUri: shareUri, authentication: credential.AsPolicy(options), options: options ?? new ShareClientOptions(), - storageSharedKeyCredential: default) + storageSharedKeyCredential: default, + sasCredential: default, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(shareUri); } @@ -301,55 +321,28 @@ public ShareClient( /// /// The shared key credential used to sign requests. /// - internal ShareClient( - Uri shareUri, - HttpPipelinePolicy authentication, - ShareClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(shareUri, nameof(shareUri)); - options ??= new ShareClientOptions(); - _uri = shareUri; - _clientConfiguration = new ShareClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - sasCredential: default, - clientDiagnostics: new ClientDiagnostics(options), - clientOptions: options); - _shareRestClient = BuildShareRestClient(shareUri); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the share that includes the - /// name of the account and the name of the share. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// /// - /// The shared access signature used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal ShareClient( Uri shareUri, HttpPipelinePolicy authentication, ShareClientOptions options, - AzureSasCredential sasCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(shareUri, nameof(shareUri)); options ??= new ShareClientOptions(); _uri = shareUri; _clientConfiguration = new ShareClientConfiguration( pipeline: options.Build(authentication), + sharedKeyCredential: storageSharedKeyCredential, sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), clientOptions: options); _shareRestClient = BuildShareRestClient(shareUri); diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs index 16dfcd55ab2c8..1d799e1515166 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClientConfiguration.cs @@ -62,7 +62,10 @@ public ShareClientConfiguration( { } - private ShareClientConfiguration( + /// + /// For internal Client Constructors that accept multiple types of authentication. + /// + internal ShareClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs index ff5f1a2be9ab6..bb7f99dc0e89f 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs @@ -228,7 +228,9 @@ public ShareDirectoryClient( directoryUri: directoryUri, authentication: (HttpPipelinePolicy)null, options: options, - storageSharedKeyCredential: null) + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -257,7 +259,9 @@ public ShareDirectoryClient( directoryUri: directoryUri, authentication: credential.AsPolicy(), options: options, - storageSharedKeyCredential: credential) + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -286,7 +290,13 @@ public ShareDirectoryClient( Uri directoryUri, AzureSasCredential credential, ShareClientOptions options = default) - : this(directoryUri, credential.AsPolicy(directoryUri), options, sasCredential:credential) + : this( + directoryUri, + credential.AsPolicy(directoryUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -317,7 +327,9 @@ public ShareDirectoryClient( directoryUri: directoryUri, authentication: credential.AsPolicy(options), options: options ?? new ShareClientOptions(), - storageSharedKeyCredential: null) + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(directoryUri); } @@ -342,99 +354,33 @@ public ShareDirectoryClient( /// /// The shared key credential used to sign requests. /// - internal ShareDirectoryClient( - Uri directoryUri, - HttpPipelinePolicy authentication, - ShareClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(directoryUri, nameof(directoryUri)); - options ??= new ShareClientOptions(); - _uri = directoryUri; - _clientConfiguration = new ShareClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - sasCredential: default, - clientDiagnostics: new ClientDiagnostics(options), - clientOptions: options); - _directoryRestClient = BuildDirectoryRestClient(directoryUri); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the directory that includes the - /// name of the account, the name of the share, and the path of the - /// directory. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// /// - /// The shared access signature used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal ShareDirectoryClient( Uri directoryUri, HttpPipelinePolicy authentication, ShareClientOptions options, - AzureSasCredential sasCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(directoryUri, nameof(directoryUri)); options ??= new ShareClientOptions(); _uri = directoryUri; _clientConfiguration = new ShareClientConfiguration( pipeline: options.Build(authentication), + sharedKeyCredential: storageSharedKeyCredential, sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), clientOptions: options); _directoryRestClient = BuildDirectoryRestClient(directoryUri); } - /// - /// Initializes a new instance of the - /// class. - /// - /// This will create an instance that uses the same diagnostics as another - /// client. This client will be used within another API call of the parent - /// client (namely Rename). This is in the case that the new child client - /// has different credentials than the parent client. - /// - /// - /// A referencing the directory that includes the - /// name of the account, the name of the share, and the path of the - /// directory. - /// - /// - /// The diagnostics from the parent client. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - internal ShareDirectoryClient( - Uri directoryUri, - ClientDiagnostics diagnostics, - ShareClientOptions options) - { - Argument.AssertNotNull(directoryUri, nameof(directoryUri)); - options ??= new ShareClientOptions(); - _uri = directoryUri; - _clientConfiguration = new ShareClientConfiguration( - pipeline: options.Build(), - sharedKeyCredential: default, - clientDiagnostics: diagnostics, - clientOptions: options); - _directoryRestClient = BuildDirectoryRestClient(directoryUri); - } - /// /// Initializes a new instance of the /// class. @@ -2613,8 +2559,7 @@ private async Task> RenameInternal( // Create the destination path with the destination SAS destDirectoryClient = new ShareDirectoryClient( destUriBuilder.ToUri(), - ClientConfiguration.ClientDiagnostics, - ClientConfiguration.ClientOptions); + ClientConfiguration); } } else diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs index 5a812432eb602..b671bb3763a24 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs @@ -238,7 +238,9 @@ public ShareFileClient( fileUri: fileUri, authentication: (HttpPipelinePolicy)null, options: options, - storageSharedKeyCredential: null) + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -266,7 +268,9 @@ public ShareFileClient( fileUri: fileUri, authentication: credential.AsPolicy(), options: options, - storageSharedKeyCredential: credential) + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -294,7 +298,13 @@ public ShareFileClient( Uri fileUri, AzureSasCredential credential, ShareClientOptions options = default) - : this(fileUri, credential.AsPolicy(fileUri), options, credential) + : this( + fileUri, + credential.AsPolicy(fileUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -325,7 +335,9 @@ public ShareFileClient( fileUri: fileUri, authentication: credential.AsPolicy(options), options: options ?? new ShareClientOptions(), - storageSharedKeyCredential: null) + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(fileUri); } @@ -350,99 +362,33 @@ public ShareFileClient( /// /// The shared key credential used to sign requests. /// - internal ShareFileClient( - Uri fileUri, - HttpPipelinePolicy authentication, - ShareClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(fileUri, nameof(fileUri)); - options ??= new ShareClientOptions(); - _uri = fileUri; - _clientConfiguration = new ShareClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - sasCredential: null, - clientDiagnostics: new ClientDiagnostics(options), - clientOptions: options); - _fileRestClient = BuildFileRestClient(fileUri); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the file that includes the - /// name of the account, the name of the share, and the path of the - /// file. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// /// - /// The shared access signature used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal ShareFileClient( Uri fileUri, HttpPipelinePolicy authentication, ShareClientOptions options, - AzureSasCredential sasCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(fileUri, nameof(fileUri)); options ??= new ShareClientOptions(); _uri = fileUri; _clientConfiguration = new ShareClientConfiguration( pipeline: options.Build(authentication), + sharedKeyCredential: storageSharedKeyCredential, sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), clientOptions: options); _fileRestClient = BuildFileRestClient(fileUri); } - /// - /// Initializes a new instance of the - /// class. - /// - /// This will create an instance that uses the same diagnostics as another - /// client. This client will be used within another API call of the parent - /// client (namely Rename). This is in the case that the new child client - /// has different credentials than the parent client. - /// - /// - /// A referencing the file that includes the - /// name of the account, the name of the share, and the path of the - /// file. - /// - /// - /// The diagnostics from the parent client. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - internal ShareFileClient( - Uri fileUri, - ClientDiagnostics diagnostics, - ShareClientOptions options) - { - Argument.AssertNotNull(fileUri, nameof(fileUri)); - options ??= new ShareClientOptions(); - _uri = fileUri; - _clientConfiguration = new ShareClientConfiguration( - pipeline: options.Build(), - sharedKeyCredential: default, - clientDiagnostics: diagnostics, - clientOptions: options); - _fileRestClient = BuildFileRestClient(fileUri); - } - /// /// Initializes a new instance of the class. /// @@ -6309,8 +6255,7 @@ private async Task> RenameInternal( // Create the destination path with the destination SAS destFileClient = new ShareFileClient( destUriBuilder.ToUri(), - ClientConfiguration.ClientDiagnostics, - ClientConfiguration.ClientOptions); + ClientConfiguration); } } else diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs index 858d20e847ca0..0a2d18d28ac3a 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs @@ -152,7 +152,13 @@ public ShareServiceClient( public ShareServiceClient( Uri serviceUri, ShareClientOptions options = default) - : this(serviceUri, (HttpPipelinePolicy)null, options, storageSharedKeyCredential:null) + : this( + serviceUri, + (HttpPipelinePolicy)null, + options, + sharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -175,7 +181,13 @@ public ShareServiceClient( Uri serviceUri, StorageSharedKeyCredential credential, ShareClientOptions options = default) - : this(serviceUri, credential.AsPolicy(), options, credential) + : this( + serviceUri, + credential.AsPolicy(), + options, + sharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -202,7 +214,13 @@ public ShareServiceClient( Uri serviceUri, AzureSasCredential credential, ShareClientOptions options = default) - : this(serviceUri, credential.AsPolicy(serviceUri), options, sasCredential:credential) + : this( + serviceUri, + credential.AsPolicy(serviceUri), + options, + sharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -256,7 +274,10 @@ public ShareServiceClient( : this( serviceUri: serviceUri, authentication: credential.AsPolicy(options), - options: options ?? new ShareClientOptions()) + options: options ?? new ShareClientOptions(), + sharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(serviceUri); } @@ -276,58 +297,31 @@ public ShareServiceClient( /// policies for authentication, retries, etc., that are applied to /// every request. /// - /// + /// /// The shared key credential used to sign requests. /// - internal ShareServiceClient( - Uri serviceUri, - HttpPipelinePolicy authentication, - ShareClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential = default) - { - Argument.AssertNotNull(serviceUri, nameof(serviceUri)); - options ??= new ShareClientOptions(); - _uri = serviceUri; - _clientConfiguration = new ShareClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - sasCredential: null, - clientDiagnostics: new ClientDiagnostics(options), - clientOptions: options); - _serviceRestClient = BuildServiceRestClient(); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the file service. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// /// - /// The shared access signature used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal ShareServiceClient( Uri serviceUri, HttpPipelinePolicy authentication, ShareClientOptions options, - AzureSasCredential sasCredential) + StorageSharedKeyCredential sharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(serviceUri, nameof(serviceUri)); options ??= new ShareClientOptions(); _uri = serviceUri; _clientConfiguration = new ShareClientConfiguration( pipeline: options.Build(authentication), - sharedKeyCredential: null, + sharedKeyCredential: sharedKeyCredential, sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), clientOptions: options); _serviceRestClient = BuildServiceRestClient(); diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs index d4c82729552ae..51f4775760440 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs @@ -353,12 +353,12 @@ public QueueClient(Uri queueUri, TokenCredential credential, QueueClientOptions /// /// The shared key credential used to sign requests. /// - /// - /// The token credential used to sign requests. - /// /// /// The SAS credential used to sign requests. /// + /// + /// The token credential used to sign requests. + /// internal QueueClient( Uri queueUri, HttpPipelinePolicy authentication, From 21ec6429387afa482ab3a071997adbbc7b3d613b Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 13:27:24 -0500 Subject: [PATCH 06/15] DataLakeServiceClient --- .../src/BlobServiceClient.cs | 18 +- .../src/Shared/BlobClientConfiguration.cs | 5 +- .../src/DataLakeClientConfiguration.cs | 5 +- .../src/DataLakeServiceClient.cs | 204 +++++++----------- .../Azure.Storage.Queues/src/QueueClient.cs | 14 +- 5 files changed, 104 insertions(+), 142 deletions(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs index d4ca2ad868241..cff4ea9f19e9e 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs @@ -419,6 +419,15 @@ internal BlobServiceClient( /// /// The transport pipeline used to send every request. /// + /// + /// The shared key credential used to sign requests. + /// + /// + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. + /// /// /// New instanc of the class. /// @@ -426,13 +435,18 @@ protected static BlobServiceClient CreateClient( Uri serviceUri, BlobClientOptions options, HttpPipelinePolicy authentication, - HttpPipeline pipeline) + HttpPipeline pipeline, + StorageSharedKeyCredential sharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { return new BlobServiceClient( serviceUri, new BlobClientConfiguration( pipeline: pipeline, - sharedKeyCredential: null, + sharedKeyCredential: sharedKeyCredential, + sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), version: options.Version, customerProvidedKey: null, diff --git a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs index f307d54ac4c0e..8d3d5ddf7bdf3 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs @@ -121,7 +121,10 @@ public BlobClientConfiguration( TrimBlobNameSlashes = trimBlobNameSlashes; } - private BlobClientConfiguration( + /// + /// Used for internal Client Constructors that accept multiple types of authentication. + /// + internal BlobClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, TokenCredential tokenCredential, diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs index 50bbcc7740145..d0e3d2e9032a5 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeClientConfiguration.cs @@ -80,7 +80,10 @@ public DataLakeClientConfiguration( TransferValidation = clientOptions.TransferValidation; } - private DataLakeClientConfiguration( + /// + /// For internal Client Constructors that accept multiple types of authentication. + /// + internal DataLakeClientConfiguration( HttpPipeline pipeline, StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs index 9760abf9fe0a3..c6fe10255581a 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs @@ -96,7 +96,13 @@ protected DataLakeServiceClient() /// A referencing the Data Lake service. /// public DataLakeServiceClient(Uri serviceUri) - : this(serviceUri, (HttpPipelinePolicy)null, null, storageSharedKeyCredential:null) + : this( + serviceUri, + (HttpPipelinePolicy)null, + options: null, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -113,7 +119,13 @@ public DataLakeServiceClient(Uri serviceUri) /// every request. /// public DataLakeServiceClient(Uri serviceUri, DataLakeClientOptions options) - : this(serviceUri, (HttpPipelinePolicy)null, options, storageSharedKeyCredential:null) + : this( + serviceUri, + (HttpPipelinePolicy)null, + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -168,10 +180,8 @@ public DataLakeServiceClient(string connectionString, DataLakeClientOptions opti _blobServiceClient = BlobServiceClientInternals.Create( _blobUri, - _clientConfiguration.Pipeline, - authPolicy, - _clientConfiguration.ClientOptions.Version.AsBlobsVersion(), - _clientConfiguration.ClientDiagnostics); + _clientConfiguration, + authPolicy); DataLakeErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); } @@ -187,7 +197,13 @@ public DataLakeServiceClient(string connectionString, DataLakeClientOptions opti /// The shared key credential used to sign requests. /// public DataLakeServiceClient(Uri serviceUri, StorageSharedKeyCredential credential) - : this(serviceUri, credential.AsPolicy(), null, credential) + : this( + serviceUri, + credential.AsPolicy(), + options: null, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -207,7 +223,13 @@ public DataLakeServiceClient(Uri serviceUri, StorageSharedKeyCredential credenti /// every request. /// public DataLakeServiceClient(Uri serviceUri, StorageSharedKeyCredential credential, DataLakeClientOptions options) - : this(serviceUri, credential.AsPolicy(), options, null, credential) + : this( + serviceUri, + credential.AsPolicy(), + options, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -250,7 +272,13 @@ public DataLakeServiceClient(Uri serviceUri, AzureSasCredential credential) /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public DataLakeServiceClient(Uri serviceUri, AzureSasCredential credential, DataLakeClientOptions options) - : this(serviceUri, credential.AsPolicy(serviceUri), options, null, credential) + : this( + serviceUri, + credential.AsPolicy(serviceUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -265,7 +293,13 @@ public DataLakeServiceClient(Uri serviceUri, AzureSasCredential credential, Data /// The token credential used to sign requests. /// public DataLakeServiceClient(Uri serviceUri, TokenCredential credential) - : this(serviceUri, credential.AsPolicy(new DataLakeClientOptions()), null, storageSharedKeyCredential:null) + : this( + serviceUri, + credential.AsPolicy(new DataLakeClientOptions()), + options: null, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(serviceUri); } @@ -286,65 +320,17 @@ public DataLakeServiceClient(Uri serviceUri, TokenCredential credential) /// every request. /// public DataLakeServiceClient(Uri serviceUri, TokenCredential credential, DataLakeClientOptions options) - : this(serviceUri, credential.AsPolicy(options), options, storageSharedKeyCredential:null) + : this( + serviceUri, + credential.AsPolicy(options), + options, + storageSharedKeyCredential:null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(serviceUri); } - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the Data Lake service - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - /// - /// The shared key credential used to sign requests. - /// - internal DataLakeServiceClient( - Uri serviceUri, - HttpPipelinePolicy authentication, - DataLakeClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - : this(serviceUri, authentication, options, null, storageSharedKeyCredential) - { - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the Data Lake service - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - /// - /// The shared key credential used to sign requests. - /// - internal DataLakeServiceClient( - Uri serviceUri, - HttpPipelinePolicy authentication, - DataLakeClientOptions options, - AzureSasCredential sasCredential) - : this(serviceUri, authentication, options, null, sasCredential) - { - } - /// /// Initializes a new instance of the /// class. @@ -368,12 +354,10 @@ internal DataLakeServiceClient( _blobServiceClient = BlobServiceClientInternals.Create( _blobUri, - _clientConfiguration.Pipeline, + _clientConfiguration, // auth is included in pipeline in client configuration. // blobs keeps it separate for niche use cases that are inaccessible from datalake clients - authentication: default, - _clientConfiguration.ClientOptions.Version.AsBlobsVersion(), - _clientConfiguration.ClientDiagnostics); + authentication: default); } /// @@ -391,65 +375,22 @@ internal DataLakeServiceClient( /// policies for authentication, retries, etc., that are applied to /// every request. /// - /// /// /// The shared key credential used to sign requests. /// - internal DataLakeServiceClient( - Uri serviceUri, - HttpPipelinePolicy authentication, - DataLakeClientOptions options, - ClientDiagnostics clientDiagnostics, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(serviceUri, nameof(serviceUri)); - options ??= new DataLakeClientOptions(); - - _uri = serviceUri; - _blobUri = new DataLakeUriBuilder(serviceUri).ToBlobUri(); - - _clientConfiguration = new DataLakeClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - clientDiagnostics: clientDiagnostics ?? new ClientDiagnostics(options), - clientOptions: options, - customerProvidedKey: options.CustomerProvidedKey); - - _blobServiceClient = BlobServiceClientInternals.Create( - _blobUri, - _clientConfiguration.Pipeline, - authentication, - _clientConfiguration.ClientOptions.Version.AsBlobsVersion(), - _clientConfiguration.ClientDiagnostics); - - DataLakeErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the Data Lake service. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - /// /// - /// The shared key credential used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal DataLakeServiceClient( Uri serviceUri, HttpPipelinePolicy authentication, DataLakeClientOptions options, - ClientDiagnostics clientDiagnostics, - AzureSasCredential sasCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(serviceUri, nameof(serviceUri)); options ??= new DataLakeClientOptions(); @@ -459,17 +400,17 @@ internal DataLakeServiceClient( _clientConfiguration = new DataLakeClientConfiguration( pipeline: options.Build(authentication), + sharedKeyCredential: storageSharedKeyCredential, sasCredential: sasCredential, - clientDiagnostics: clientDiagnostics ?? new ClientDiagnostics(options), + tokenCredential: tokenCredential, + clientDiagnostics: new ClientDiagnostics(options), clientOptions: options, customerProvidedKey: options.CustomerProvidedKey); _blobServiceClient = BlobServiceClientInternals.Create( _blobUri, - _clientConfiguration.Pipeline, - authentication, - _clientConfiguration.ClientOptions.Version.AsBlobsVersion(), - _clientConfiguration.ClientDiagnostics); + _clientConfiguration, + authentication); DataLakeErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); } @@ -482,19 +423,20 @@ private class BlobServiceClientInternals : BlobServiceClient { public static BlobServiceClient Create( Uri uri, - HttpPipeline pipeline, - HttpPipelinePolicy authentication, - BlobClientOptions.ServiceVersion version, - ClientDiagnostics diagnostics) + DataLakeClientConfiguration clientConfiguration, + HttpPipelinePolicy authentication) { return BlobServiceClient.CreateClient( uri, - new BlobClientOptions(version) + new BlobClientOptions(clientConfiguration.ClientOptions.Version.AsBlobsVersion()) { - Diagnostics = { IsDistributedTracingEnabled = diagnostics.IsActivityEnabled } + Diagnostics = { IsDistributedTracingEnabled = clientConfiguration.ClientDiagnostics.IsActivityEnabled } }, authentication, - pipeline); + clientConfiguration.Pipeline, + clientConfiguration.SharedKeyCredential, + clientConfiguration.SasCredential, + clientConfiguration.TokenCredential); } } #endregion ctors diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs index 51f4775760440..b7ffcf191da36 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs @@ -238,7 +238,7 @@ public QueueClient(Uri queueUri, QueueClientOptions options = default) queueUri, (HttpPipelinePolicy)null, options, - storageSharedKeyCredential: null, + sharedKeyCredential: null, sasCredential: null, tokenCredential: null) { @@ -266,7 +266,7 @@ public QueueClient(Uri queueUri, StorageSharedKeyCredential credential, QueueCli queueUri, credential.AsPolicy(), options, - storageSharedKeyCredential: credential, + sharedKeyCredential: credential, sasCredential: null, tokenCredential: null) { @@ -298,7 +298,7 @@ public QueueClient(Uri queueUri, AzureSasCredential credential, QueueClientOptio queueUri, credential.AsPolicy(queueUri), options, - storageSharedKeyCredential: null, + sharedKeyCredential: null, sasCredential: credential, tokenCredential: null) { @@ -326,7 +326,7 @@ public QueueClient(Uri queueUri, TokenCredential credential, QueueClientOptions queueUri, credential.AsPolicy(options), options, - storageSharedKeyCredential: null, + sharedKeyCredential: null, sasCredential: null, tokenCredential: credential) { @@ -350,7 +350,7 @@ public QueueClient(Uri queueUri, TokenCredential credential, QueueClientOptions /// policies for authentication, retries, etc., that are applied to /// every request. /// - /// + /// /// The shared key credential used to sign requests. /// /// @@ -363,7 +363,7 @@ internal QueueClient( Uri queueUri, HttpPipelinePolicy authentication, QueueClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential, + StorageSharedKeyCredential sharedKeyCredential, AzureSasCredential sasCredential, TokenCredential tokenCredential) { @@ -373,7 +373,7 @@ internal QueueClient( options ??= new QueueClientOptions(); _clientConfiguration = new QueueClientConfiguration( pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, + sharedKeyCredential: sharedKeyCredential, sasCredential: sasCredential, tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), From c330aec3e2b754039f257c798f770a6660c92473 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 14:40:59 -0500 Subject: [PATCH 07/15] FileSystemClient --- .../src/DataLakeFileSystemClient.cs | 114 +++++++++--------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs index 3938994706ca5..77abac7108f1c 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs @@ -146,7 +146,13 @@ protected DataLakeFileSystemClient() /// name of the account and the name of the file system. /// public DataLakeFileSystemClient(Uri fileSystemUri) - : this(fileSystemUri, (HttpPipelinePolicy)null, null, storageSharedKeyCredential: null) + : this( + fileSystemUri, + (HttpPipelinePolicy)null, + options: null, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -164,7 +170,13 @@ public DataLakeFileSystemClient(Uri fileSystemUri) /// every request. /// public DataLakeFileSystemClient(Uri fileSystemUri, DataLakeClientOptions options) - : this(fileSystemUri, (HttpPipelinePolicy)null, options, storageSharedKeyCredential: null) + : this( + fileSystemUri, + (HttpPipelinePolicy)null, + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -254,7 +266,13 @@ public DataLakeFileSystemClient(string connectionString, string fileSystemName, /// The shared key credential used to sign requests. /// public DataLakeFileSystemClient(Uri fileSystemUri, StorageSharedKeyCredential credential) - : this(fileSystemUri, credential.AsPolicy(), null, credential) + : this( + fileSystemUri, + credential.AsPolicy(), + options: null, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -275,7 +293,13 @@ public DataLakeFileSystemClient(Uri fileSystemUri, StorageSharedKeyCredential cr /// every request. /// public DataLakeFileSystemClient(Uri fileSystemUri, StorageSharedKeyCredential credential, DataLakeClientOptions options) - : this(fileSystemUri, credential.AsPolicy(), options, credential) + : this( + fileSystemUri, + credential.AsPolicy(), + options, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -320,7 +344,13 @@ public DataLakeFileSystemClient(Uri fileSystemUri, AzureSasCredential credential /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public DataLakeFileSystemClient(Uri fileSystemUri, AzureSasCredential credential, DataLakeClientOptions options) - : this(fileSystemUri, credential.AsPolicy(fileSystemUri), options, credential) + : this( + fileSystemUri, + credential.AsPolicy(fileSystemUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -336,7 +366,13 @@ public DataLakeFileSystemClient(Uri fileSystemUri, AzureSasCredential credential /// The token credential used to sign requests. /// public DataLakeFileSystemClient(Uri fileSystemUri, TokenCredential credential) - : this(fileSystemUri, credential.AsPolicy(new DataLakeClientOptions()), null, storageSharedKeyCredential:null) + : this( + fileSystemUri, + credential.AsPolicy(new DataLakeClientOptions()), + options: null, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(fileSystemUri); } @@ -358,7 +394,13 @@ public DataLakeFileSystemClient(Uri fileSystemUri, TokenCredential credential) /// every request. /// public DataLakeFileSystemClient(Uri fileSystemUri, TokenCredential credential, DataLakeClientOptions options) - : this(fileSystemUri, credential.AsPolicy(options), options, storageSharedKeyCredential:null) + : this( + fileSystemUri, + credential.AsPolicy(options), + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(fileSystemUri); } @@ -382,61 +424,19 @@ public DataLakeFileSystemClient(Uri fileSystemUri, TokenCredential credential, D /// /// The shared key credential used to sign requests. /// - internal DataLakeFileSystemClient( - Uri fileSystemUri, - HttpPipelinePolicy authentication, - DataLakeClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(fileSystemUri, nameof(fileSystemUri)); - DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(fileSystemUri); - options ??= new DataLakeClientOptions(); - _uri = fileSystemUri; - _blobUri = uriBuilder.ToBlobUri(); - _dfsUri = uriBuilder.ToDfsUri(); - - _clientConfiguration = new DataLakeClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - clientDiagnostics: new ClientDiagnostics(options), - clientOptions: options, - customerProvidedKey: options.CustomerProvidedKey); - - _containerClient = BlobContainerClientInternals.Create( - _blobUri, - _clientConfiguration); - - (FileSystemRestClient dfsFileSystemRestClient, FileSystemRestClient blobFileSystemRestClient) = BuildFileSystemRestClients(_dfsUri, _blobUri); - _fileSystemRestClient = dfsFileSystemRestClient; - _blobFileSystemRestClient = blobFileSystemRestClient; - - DataLakeErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the file system that includes the - /// name of the account and the name of the file system. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// /// - /// The shared key credential used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal DataLakeFileSystemClient( Uri fileSystemUri, HttpPipelinePolicy authentication, DataLakeClientOptions options, - AzureSasCredential sasCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(fileSystemUri, nameof(fileSystemUri)); DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(fileSystemUri); @@ -447,7 +447,9 @@ internal DataLakeFileSystemClient( _clientConfiguration = new DataLakeClientConfiguration( pipeline: options.Build(authentication), + sharedKeyCredential: storageSharedKeyCredential, sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), clientOptions: options, customerProvidedKey: options.CustomerProvidedKey); From 6e59a76c969030d422a4f65249d151c4fb9dc931 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 14:45:01 -0500 Subject: [PATCH 08/15] PathClient --- .../src/DataLakePathClient.cs | 103 ++++++++---------- 1 file changed, 44 insertions(+), 59 deletions(-) diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs index 62025096c62a0..eebfb201803fa 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs @@ -220,7 +220,13 @@ public DataLakePathClient(Uri pathUri) /// applied to every request. /// public DataLakePathClient(Uri pathUri, DataLakeClientOptions options) - : this(pathUri, (HttpPipelinePolicy)null, options, storageSharedKeyCredential: null) + : this( + pathUri, + (HttpPipelinePolicy)null, + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -320,7 +326,13 @@ public DataLakePathClient( /// The shared key credential used to sign requests. /// public DataLakePathClient(Uri pathUri, StorageSharedKeyCredential credential) - : this(pathUri, credential.AsPolicy(), null, credential) + : this( + pathUri, + credential.AsPolicy(), + options: null, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -342,7 +354,13 @@ public DataLakePathClient(Uri pathUri, StorageSharedKeyCredential credential) /// every request. /// public DataLakePathClient(Uri pathUri, StorageSharedKeyCredential credential, DataLakeClientOptions options) - : this(pathUri, credential.AsPolicy(), options, credential) + : this( + pathUri, + credential.AsPolicy(), + options, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -389,7 +407,13 @@ public DataLakePathClient(Uri pathUri, AzureSasCredential credential) /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public DataLakePathClient(Uri pathUri, AzureSasCredential credential, DataLakeClientOptions options) - : this(pathUri, credential.AsPolicy(pathUri), options, credential) + : this( + pathUri, + credential.AsPolicy(pathUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -429,7 +453,13 @@ public DataLakePathClient(Uri pathUri, TokenCredential credential) /// every request. /// public DataLakePathClient(Uri pathUri, TokenCredential credential, DataLakeClientOptions options) - : this(pathUri, credential.AsPolicy(options), options, storageSharedKeyCredential: null) + : this( + pathUri, + credential.AsPolicy(options), + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(pathUri); } @@ -521,66 +551,19 @@ internal DataLakePathClient( /// /// The shared key credential used to sign requests. /// - internal DataLakePathClient( - Uri pathUri, - HttpPipelinePolicy authentication, - DataLakeClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(pathUri, nameof(pathUri)); - DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(pathUri); - options ??= new DataLakeClientOptions(); - _uri = pathUri; - _blobUri = uriBuilder.ToBlobUri(); - _dfsUri = uriBuilder.ToDfsUri(); - - _clientConfiguration = new DataLakeClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: storageSharedKeyCredential, - clientDiagnostics: new ClientDiagnostics(options), - clientOptions: options, - customerProvidedKey: options.CustomerProvidedKey); - - _blockBlobClient = BlockBlobClientInternals.Create(_blobUri, _clientConfiguration); - - uriBuilder.DirectoryOrFilePath = null; - - _fileSystemClient = new DataLakeFileSystemClient( - uriBuilder.ToDfsUri(), - _clientConfiguration); - - (PathRestClient dfsPathRestClient, PathRestClient blobPathRestClient) = BuildPathRestClients(_dfsUri, _blobUri); - _pathRestClient = dfsPathRestClient; - _blobPathRestClient = blobPathRestClient; - - DataLakeErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the path that includes the - /// name of the account, the name of the file system, and the path to - /// the resource. - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// /// - /// The shared key credential used to sign requests. + /// The SAS credential used to sign requests. + /// + /// + /// The token credential used to sign requests. /// internal DataLakePathClient( Uri pathUri, HttpPipelinePolicy authentication, DataLakeClientOptions options, - AzureSasCredential sasCredential) + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, + TokenCredential tokenCredential) { Argument.AssertNotNull(pathUri, nameof(pathUri)); DataLakeUriBuilder uriBuilder = new DataLakeUriBuilder(pathUri); @@ -591,7 +574,9 @@ internal DataLakePathClient( _clientConfiguration = new DataLakeClientConfiguration( pipeline: options.Build(authentication), + sharedKeyCredential: storageSharedKeyCredential, sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), clientOptions: options, customerProvidedKey: options.CustomerProvidedKey); From 1f368a3abd65a6f56fe5d82262e113fcc0ab77f8 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 14:47:12 -0500 Subject: [PATCH 09/15] Finished DataLake --- .../src/DataLakeDirectoryClient.cs | 16 ++++++++++++++-- .../src/DataLakeFileClient.cs | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeDirectoryClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeDirectoryClient.cs index 48b7dd6e22bc1..eefd6242a39c0 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeDirectoryClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeDirectoryClient.cs @@ -272,7 +272,13 @@ internal DataLakeDirectoryClient HttpPipelinePolicy authentication, DataLakeClientOptions options, StorageSharedKeyCredential storageSharedKeyCredential) - : base(directoryUri, authentication, options, storageSharedKeyCredential) + : base( + directoryUri, + authentication, + options, + storageSharedKeyCredential: storageSharedKeyCredential, + sasCredential: null, + tokenCredential: null) { } @@ -301,7 +307,13 @@ internal DataLakeDirectoryClient HttpPipelinePolicy authentication, DataLakeClientOptions options, AzureSasCredential sasCredential) - : base(directoryUri, authentication, options, sasCredential) + : base( + directoryUri, + authentication, + options, + storageSharedKeyCredential: null, + sasCredential: sasCredential, + tokenCredential: null) { } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs index 0d4ff604d7cae..55a00856b1bbb 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs @@ -288,7 +288,13 @@ internal DataLakeFileClient( HttpPipelinePolicy authentication, DataLakeClientOptions options, StorageSharedKeyCredential storageSharedKeyCredential) - : base(fileUri, authentication, options, storageSharedKeyCredential) + : base( + fileUri, + authentication, + options, + storageSharedKeyCredential: storageSharedKeyCredential, + sasCredential: null, + tokenCredential: null) { } @@ -317,7 +323,12 @@ internal DataLakeFileClient( HttpPipelinePolicy authentication, DataLakeClientOptions options, AzureSasCredential sasCredential) - : base(fileUri, authentication, options, sasCredential) + : base(fileUri, + authentication, + options, + storageSharedKeyCredential: null, + sasCredential: sasCredential, + tokenCredential: null) { } From e211d26cb6eca47413aef6632bb9fd17d7a396de Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 15:12:06 -0500 Subject: [PATCH 10/15] BlobBaseClient --- .../Azure.Storage.Blobs/src/BlobBaseClient.cs | 102 +++++++----------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index 9e8a5b2d58d85..049374af768fb 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs @@ -238,7 +238,13 @@ public BlobBaseClient(string connectionString, string blobContainerName, string /// every request. /// public BlobBaseClient(Uri blobUri, BlobClientOptions options = default) - : this(blobUri, (HttpPipelinePolicy)null, options, storageSharedKeyCredential: null) + : this( + blobUri, + (HttpPipelinePolicy)null, + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: null) { } @@ -261,7 +267,13 @@ public BlobBaseClient(Uri blobUri, BlobClientOptions options = default) /// every request. /// public BlobBaseClient(Uri blobUri, StorageSharedKeyCredential credential, BlobClientOptions options = default) - : this(blobUri, credential.AsPolicy(), options, storageSharedKeyCredential: credential) + : this( + blobUri, + credential.AsPolicy(), + options, + storageSharedKeyCredential: credential, + sasCredential: null, + tokenCredential: null) { } @@ -288,7 +300,13 @@ public BlobBaseClient(Uri blobUri, StorageSharedKeyCredential credential, BlobCl /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public BlobBaseClient(Uri blobUri, AzureSasCredential credential, BlobClientOptions options = default) - : this(blobUri, credential.AsPolicy(blobUri), options, storageSharedKeyCredential: null) + : this( + blobUri, + credential.AsPolicy(blobUri), + options, + storageSharedKeyCredential: null, + sasCredential: credential, + tokenCredential: null) { } @@ -311,7 +329,13 @@ public BlobBaseClient(Uri blobUri, AzureSasCredential credential, BlobClientOpti /// every request. /// public BlobBaseClient(Uri blobUri, TokenCredential credential, BlobClientOptions options = default) - : this(blobUri, credential.AsPolicy(options), options, credential) + : this( + blobUri, + credential.AsPolicy(options), + options, + storageSharedKeyCredential: null, + sasCredential: null, + tokenCredential: credential) { Errors.VerifyHttpsTokenAuth(blobUri); } @@ -334,6 +358,12 @@ public BlobBaseClient(Uri blobUri, TokenCredential credential, BlobClientOptions /// policies for authentication, retries, etc., that are applied to /// every request. /// + /// + /// The shared key credential used to sign requests. + /// + /// + /// The SAS credential used to sign requests. + /// /// /// The token credential used to sign requests. /// @@ -341,6 +371,8 @@ internal BlobBaseClient( Uri blobUri, HttpPipelinePolicy authentication, BlobClientOptions options, + StorageSharedKeyCredential storageSharedKeyCredential, + AzureSasCredential sasCredential, TokenCredential tokenCredential) { Argument.AssertNotNull(blobUri, nameof(blobUri)); @@ -359,69 +391,11 @@ internal BlobBaseClient( } } - _clientConfiguration = new BlobClientConfiguration( - pipeline: options.Build(authentication), - tokenCredential: tokenCredential, - clientDiagnostics: new ClientDiagnostics(options), - version: options.Version, - customerProvidedKey: options.CustomerProvidedKey, - transferValidation: options.TransferValidation, - encryptionScope: options.EncryptionScope, - trimBlobNameSlashes: options.TrimBlobNameSlashes); - - _clientSideEncryption = options._clientSideEncryptionOptions?.Clone(); - _blobRestClient = BuildBlobRestClient(blobUri); - - BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); - BlobErrors.VerifyCpkAndEncryptionScopeNotBothSet(_clientConfiguration.CustomerProvidedKey, _clientConfiguration.EncryptionScope); - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the blob that includes the - /// name of the account, the name of the container, and the name of - /// the blob. - /// This is likely to be similar to "https://{account_name}.blob.core.windows.net/{container_name}/{blob_name}". - /// - /// - /// An optional authentication policy used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - /// - /// The shared key credential used to sign requests. - /// - internal BlobBaseClient( - Uri blobUri, - HttpPipelinePolicy authentication, - BlobClientOptions options, - StorageSharedKeyCredential storageSharedKeyCredential) - { - Argument.AssertNotNull(blobUri, nameof(blobUri)); - options ??= new BlobClientOptions(); - _uri = blobUri; - if (!string.IsNullOrEmpty(blobUri.Query)) - { - UriQueryParamsCollection queryParamsCollection = new UriQueryParamsCollection(blobUri.Query); - if (queryParamsCollection.ContainsKey(Constants.SnapshotParameterName)) - { - _snapshot = System.Web.HttpUtility.ParseQueryString(blobUri.Query).Get(Constants.SnapshotParameterName); - } - if (queryParamsCollection.ContainsKey(Constants.VersionIdParameterName)) - { - _blobVersionId = System.Web.HttpUtility.ParseQueryString(blobUri.Query).Get(Constants.VersionIdParameterName); - } - } - _clientConfiguration = new BlobClientConfiguration( pipeline: options.Build(authentication), sharedKeyCredential: storageSharedKeyCredential, + sasCredential: sasCredential, + tokenCredential: tokenCredential, clientDiagnostics: new ClientDiagnostics(options), version: options.Version, customerProvidedKey: options.CustomerProvidedKey, From 27013d19fc1edc1ca56b1c45843695b336d4185b Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 15:19:46 -0500 Subject: [PATCH 11/15] BlobContainerClient --- .../src/BlobContainerClient.cs | 45 +++++-------------- .../src/Shared/BlobClientConfiguration.cs | 4 +- 2 files changed, 12 insertions(+), 37 deletions(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs index 4e38669a05cd5..a0167f3169377 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs @@ -226,7 +226,7 @@ public BlobContainerClient(string connectionString, string blobContainerName, Bl /// every request. /// public BlobContainerClient(Uri blobContainerUri, BlobClientOptions options = default) - : this(blobContainerUri, (HttpPipelinePolicy)null, options) + : this(blobContainerUri, (AzureSasCredential)null, options) { } @@ -294,38 +294,15 @@ public BlobContainerClient(Uri blobContainerUri, StorageSharedKeyCredential cred /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public BlobContainerClient(Uri blobContainerUri, AzureSasCredential credential, BlobClientOptions options = default) - : this(blobContainerUri, credential.AsPolicy(blobContainerUri), options) { - } - - /// - /// Initializes a new instance of the - /// class. - /// - /// - /// A referencing the blob container that includes the - /// name of the account and the name of the container. - /// This is likely to be similar to "https://{account_name}.blob.core.windows.net/{container_name}". - /// - /// - /// The token credential used to sign requests. - /// - /// - /// Optional client options that define the transport pipeline - /// policies for authentication, retries, etc., that are applied to - /// every request. - /// - public BlobContainerClient(Uri blobContainerUri, TokenCredential credential, BlobClientOptions options = default) - { - Errors.VerifyHttpsTokenAuth(blobContainerUri); Argument.AssertNotNull(blobContainerUri, nameof(blobContainerUri)); _uri = blobContainerUri; - _authenticationPolicy = credential.AsPolicy(options); + _authenticationPolicy = credential.AsPolicy(blobContainerUri); options ??= new BlobClientOptions(); _clientConfiguration = new BlobClientConfiguration( pipeline: options.Build(_authenticationPolicy), - tokenCredential: credential, + sasCredential: credential, clientDiagnostics: new ClientDiagnostics(options), version: options.Version, customerProvidedKey: options.CustomerProvidedKey, @@ -349,27 +326,25 @@ public BlobContainerClient(Uri blobContainerUri, TokenCredential credential, Blo /// name of the account and the name of the container. /// This is likely to be similar to "https://{account_name}.blob.core.windows.net/{container_name}". /// - /// - /// An optional authentication policy used to sign requests. + /// + /// The token credential used to sign requests. /// /// /// Optional client options that define the transport pipeline /// policies for authentication, retries, etc., that are applied to /// every request. /// - internal BlobContainerClient( - Uri blobContainerUri, - HttpPipelinePolicy authentication, - BlobClientOptions options) + public BlobContainerClient(Uri blobContainerUri, TokenCredential credential, BlobClientOptions options = default) { + Errors.VerifyHttpsTokenAuth(blobContainerUri); Argument.AssertNotNull(blobContainerUri, nameof(blobContainerUri)); _uri = blobContainerUri; - _authenticationPolicy = authentication; + _authenticationPolicy = credential.AsPolicy(options); options ??= new BlobClientOptions(); _clientConfiguration = new BlobClientConfiguration( - pipeline: options.Build(authentication), - sharedKeyCredential: null, + pipeline: options.Build(_authenticationPolicy), + tokenCredential: credential, clientDiagnostics: new ClientDiagnostics(options), version: options.Version, customerProvidedKey: options.CustomerProvidedKey, diff --git a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs index 8d3d5ddf7bdf3..26b6627453269 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Shared/BlobClientConfiguration.cs @@ -83,14 +83,14 @@ public BlobClientConfiguration( /// public BlobClientConfiguration( HttpPipeline pipeline, - AzureSasCredential azureSasCredential, + AzureSasCredential sasCredential, ClientDiagnostics clientDiagnostics, BlobClientOptions.ServiceVersion version, CustomerProvidedKey? customerProvidedKey, TransferValidationOptions transferValidation, string encryptionScope, bool trimBlobNameSlashes) - : base(pipeline, azureSasCredential, clientDiagnostics) + : base(pipeline, sasCredential, clientDiagnostics) { Version = version; CustomerProvidedKey = customerProvidedKey; From 8337313e4fb086ab1fe4836a674fa2961b8a3f02 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 15:41:12 -0500 Subject: [PATCH 12/15] Fixed build issue --- .../src/BlobServiceClient.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs index cff4ea9f19e9e..501e5854c7ca3 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs @@ -457,6 +457,53 @@ protected static BlobServiceClient CreateClient( clientSideEncryption: null); } + /// + /// Intended for DataLake to create a backing blob client. + /// + /// Initializes a new instance of the + /// class. + /// + /// + /// A referencing the block blob that includes the + /// name of the account, the name of the container, and the name of + /// the blob. + /// + /// + /// Optional client options that define the transport pipeline + /// policies for authentication, retries, etc., that are applied to + /// every request. + /// + /// + /// An optional authentication policy used to sign requests. + /// + /// + /// The transport pipeline used to send every request. + /// + /// + /// New instanc of the class. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected static BlobServiceClient CreateClient( + Uri serviceUri, + BlobClientOptions options, + HttpPipelinePolicy authentication, + HttpPipeline pipeline) + { + return new BlobServiceClient( + serviceUri, + new BlobClientConfiguration( + pipeline: pipeline, + sharedKeyCredential: null, + clientDiagnostics: new ClientDiagnostics(options), + version: options.Version, + customerProvidedKey: null, + transferValidation: options.TransferValidation, + encryptionScope: null, + trimBlobNameSlashes: options.TrimBlobNameSlashes), + authentication, + clientSideEncryption: null); + } + private ServiceRestClient BuildServiceRestClient(Uri uri) => new ServiceRestClient( clientDiagnostics: _clientConfiguration.ClientDiagnostics, From c14957bf2483ffadf5ca52fddb58f5cd9341e2ec Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 15:43:58 -0500 Subject: [PATCH 13/15] BlobServiceClient --- .../src/BlobServiceClient.cs | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs index 501e5854c7ca3..08af5e3580d60 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs @@ -225,7 +225,7 @@ public BlobServiceClient(Uri serviceUri, StorageSharedKeyCredential credential, /// This constructor should only be used when shared access signature needs to be updated during lifespan of this client. /// public BlobServiceClient(Uri serviceUri, AzureSasCredential credential, BlobClientOptions options = default) - : this(serviceUri, credential.AsPolicy(serviceUri), options ?? new BlobClientOptions()) + : this(serviceUri, credential.AsPolicy(serviceUri), credential, options ?? new BlobClientOptions()) { } @@ -364,6 +364,45 @@ internal BlobServiceClient( { } + /// + /// Initializes a new instance of the + /// class. + /// + /// + /// A referencing the blob service. + /// This is likely to be similar to "https://{account_name}.blob.core.windows.net". + /// + /// + /// An optional authentication policy used to sign requests. + /// + /// + /// Optional SAS credential used to sign requests and generate sas. + /// + /// + /// Optional client options that define the transport pipeline + /// policies for authentication, retries, etc., that are applied to + /// every request. + /// + internal BlobServiceClient( + Uri serviceUri, + HttpPipelinePolicy authentication, + AzureSasCredential sasCredential, + BlobClientOptions options) + : this(serviceUri, + new BlobClientConfiguration( + pipeline: options.Build(authentication), + sasCredential: sasCredential, + clientDiagnostics: new ClientDiagnostics(options), + version: options?.Version ?? BlobClientOptions.LatestVersion, + customerProvidedKey: options?.CustomerProvidedKey, + transferValidation: options.TransferValidation, + encryptionScope: options?.EncryptionScope, + trimBlobNameSlashes: options?.TrimBlobNameSlashes ?? false), + authentication, + options?._clientSideEncryptionOptions?.Clone()) + { + } + /// /// Initializes a new instance of the /// class. From 132afbb30e3e48c8b5f0ab3cfe9ba9387c50c76f Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 15:56:20 -0500 Subject: [PATCH 14/15] Fixed broken tests --- .../src/BlobContainerClient.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs index a0167f3169377..f28a92e42523e 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.IO; using System.Linq; +using System.Net; using System.Threading; using System.Threading.Tasks; using Azure.Core; @@ -226,8 +227,29 @@ public BlobContainerClient(string connectionString, string blobContainerName, Bl /// every request. /// public BlobContainerClient(Uri blobContainerUri, BlobClientOptions options = default) - : this(blobContainerUri, (AzureSasCredential)null, options) { + Argument.AssertNotNull(blobContainerUri, nameof(blobContainerUri)); + _uri = blobContainerUri; + _authenticationPolicy = null; + options ??= new BlobClientOptions(); + + _clientConfiguration = new BlobClientConfiguration( + pipeline: options.Build(null), + sharedKeyCredential: null, + sasCredential: null, + tokenCredential: null, + clientDiagnostics: new ClientDiagnostics(options), + version: options.Version, + customerProvidedKey: options.CustomerProvidedKey, + transferValidation: options.TransferValidation, + encryptionScope: options.EncryptionScope, + trimBlobNameSlashes: options.TrimBlobNameSlashes); + + _clientSideEncryption = options._clientSideEncryptionOptions?.Clone(); + _containerRestClient = BuildContainerRestClient(blobContainerUri); + + BlobErrors.VerifyHttpsCustomerProvidedKey(_uri, _clientConfiguration.CustomerProvidedKey); + BlobErrors.VerifyCpkAndEncryptionScopeNotBothSet(_clientConfiguration.CustomerProvidedKey, _clientConfiguration.EncryptionScope); } /// From 47fe754919a50fce0d7097f4f15ae83b2276fd67 Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Tue, 18 Jul 2023 16:30:14 -0500 Subject: [PATCH 15/15] Export API --- .../Azure.Storage.Blobs/api/Azure.Storage.Blobs.net6.0.cs | 2 ++ .../api/Azure.Storage.Blobs.netstandard2.0.cs | 2 ++ .../api/Azure.Storage.Blobs.netstandard2.1.cs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.net6.0.cs b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.net6.0.cs index 3a0dae703547e..4a664e98f0cac 100644 --- a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.net6.0.cs +++ b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.net6.0.cs @@ -161,7 +161,9 @@ public BlobServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCr public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected static Azure.Storage.Blobs.BlobServiceClient CreateClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy authentication, Azure.Core.Pipeline.HttpPipeline pipeline) { throw null; } + protected static Azure.Storage.Blobs.BlobServiceClient CreateClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy authentication, Azure.Core.Pipeline.HttpPipeline pipeline, Azure.Storage.StorageSharedKeyCredential sharedKeyCredential, Azure.AzureSasCredential sasCredential, Azure.Core.TokenCredential tokenCredential) { throw null; } public virtual Azure.Response DeleteBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable FindBlobsByTags(string tagFilterSqlExpression, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs index 3a0dae703547e..4a664e98f0cac 100644 --- a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs @@ -161,7 +161,9 @@ public BlobServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCr public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected static Azure.Storage.Blobs.BlobServiceClient CreateClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy authentication, Azure.Core.Pipeline.HttpPipeline pipeline) { throw null; } + protected static Azure.Storage.Blobs.BlobServiceClient CreateClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy authentication, Azure.Core.Pipeline.HttpPipeline pipeline, Azure.Storage.StorageSharedKeyCredential sharedKeyCredential, Azure.AzureSasCredential sasCredential, Azure.Core.TokenCredential tokenCredential) { throw null; } public virtual Azure.Response DeleteBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable FindBlobsByTags(string tagFilterSqlExpression, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.1.cs b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.1.cs index 3a0dae703547e..4a664e98f0cac 100644 --- a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.1.cs +++ b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.1.cs @@ -161,7 +161,9 @@ public BlobServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCr public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] protected static Azure.Storage.Blobs.BlobServiceClient CreateClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy authentication, Azure.Core.Pipeline.HttpPipeline pipeline) { throw null; } + protected static Azure.Storage.Blobs.BlobServiceClient CreateClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy authentication, Azure.Core.Pipeline.HttpPipeline pipeline, Azure.Storage.StorageSharedKeyCredential sharedKeyCredential, Azure.AzureSasCredential sasCredential, Azure.Core.TokenCredential tokenCredential) { throw null; } public virtual Azure.Response DeleteBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable FindBlobsByTags(string tagFilterSqlExpression, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }