diff --git a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md index 497c0a84ac722..5ab268614ffee 100644 --- a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md @@ -2,6 +2,7 @@ ## 12.8.0-beta.1 (Unreleased) - Fixed bug where BlobContainerClient.GetBlobClient(), BlobContainerClient.GetParentServiceClient(), BlobServiceClient.GetBlobContainerClient(), BlobBaseClient.WithClientSideEncryptionOptions(), BlobBaseClient.GetParentBlobContainerClient(), BlobBaseClient.WithSnapshot() and BlobBaseClient.WithVersion() created clients that could not generate a SAS from clients that could generate a SAS +- Added IsHierarchicalNamespaceEnabled to AccountInfo. ## 12.7.0 (2020-11-10) - Includes all features from 12.7.0-preview.1 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 3ba3ba256b9e8..6e72d3e03c485 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 @@ -209,6 +209,7 @@ public partial class AccountInfo { internal AccountInfo() { } public Azure.Storage.Blobs.Models.AccountKind AccountKind { get { throw null; } } + public bool IsHierarchicalNamespaceEnabled { get { throw null; } } public Azure.Storage.Blobs.Models.SkuName SkuName { get { throw null; } } } public enum AccountKind @@ -827,7 +828,9 @@ public BlobSignedIdentifier() { } } public static partial class BlobsModelFactory { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.AccountInfo AccountInfo(Azure.Storage.Blobs.Models.SkuName skuName, Azure.Storage.Blobs.Models.AccountKind accountKind) { throw null; } + public static Azure.Storage.Blobs.Models.AccountInfo AccountInfo(Azure.Storage.Blobs.Models.SkuName skuName, Azure.Storage.Blobs.Models.AccountKind accountKind, bool isHierarchicalNamespaceEnabled) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobAppendInfo BlobAppendInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, byte[] contentHash, byte[] contentCrc64, string blobAppendOffset, int blobCommittedBlockCount, bool isServerEncrypted, string encryptionKeySha256) { throw null; } public static Azure.Storage.Blobs.Models.BlobAppendInfo BlobAppendInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, byte[] contentHash, byte[] contentCrc64, string blobAppendOffset, int blobCommittedBlockCount, bool isServerEncrypted, string encryptionKeySha256, string encryptionScope) { throw null; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs index 5b1894c6b59e7..55642f369ff41 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs @@ -918,6 +918,10 @@ internal static Azure.Core.HttpMessage GetAccountInfoAsync_CreateMessage( { _value.AccountKind = (Azure.Storage.Blobs.Models.AccountKind)System.Enum.Parse(typeof(Azure.Storage.Blobs.Models.AccountKind), _header, false); } + if (response.Headers.TryGetValue("x-ms-is-hns-enabled", out _header)) + { + _value.IsHierarchicalNamespaceEnabled = bool.Parse(_header); + } // Create the response return Response.FromValue(_value, response); @@ -15244,6 +15248,11 @@ public partial class AccountInfo /// public Azure.Storage.Blobs.Models.AccountKind AccountKind { get; internal set; } + /// + /// Version 2019-07-07 and newer. Indicates if the account has a hierarchical namespace enabled. + /// + public bool IsHierarchicalNamespaceEnabled { get; internal set; } + /// /// Prevent direct instantiation of AccountInfo instances. /// You can use BlobsModelFactory.AccountInfo instead. @@ -15261,12 +15270,14 @@ public static partial class BlobsModelFactory /// public static AccountInfo AccountInfo( Azure.Storage.Blobs.Models.SkuName skuName, - Azure.Storage.Blobs.Models.AccountKind accountKind) + Azure.Storage.Blobs.Models.AccountKind accountKind, + bool isHierarchicalNamespaceEnabled) { return new AccountInfo() { SkuName = skuName, AccountKind = accountKind, + IsHierarchicalNamespaceEnabled = isHierarchicalNamespaceEnabled, }; } } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs index c5a2e0c8bdcf8..67375c21bd29d 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs @@ -1002,5 +1002,20 @@ public static BlobContainerProperties BlobContainerProperties( Metadata = metadata, HasImmutabilityPolicy = hasImmutabilityPolicy, }; + + /// + /// Creates a new AccountInfo instance for mocking. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static AccountInfo AccountInfo( + Azure.Storage.Blobs.Models.SkuName skuName, + Azure.Storage.Blobs.Models.AccountKind accountKind) + { + return new AccountInfo() + { + SkuName = skuName, + AccountKind = accountKind, + }; + } } } diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs index 1f7cef27e21d2..2ed075bef7742 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs @@ -322,6 +322,34 @@ public async Task GetAccountInfoAsync() Assert.IsNotNull(response.GetRawResponse().Headers.RequestId); } + [Test] + [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_07_07)] + public async Task GetAccountInfoAsync_HnsFalse() + { + // Arrange + BlobServiceClient service = GetServiceClient_SharedKey(); + + // Act + Response response = await service.GetAccountInfoAsync(); + + // Assert + Assert.IsFalse(response.Value.IsHierarchicalNamespaceEnabled); + } + + [Test] + [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_07_07)] + public async Task GetAccountInfoAsync_HnsTrue() + { + // Arrange + BlobServiceClient service = GetServiceClient_Hns(); + + // Act + Response response = await service.GetAccountInfoAsync(); + + // Assert + Assert.IsTrue(response.Value.IsHierarchicalNamespaceEnabled); + } + [Test] public async Task GetAccountInfoAsync_Error() { diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsFalse.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsFalse.json new file mode 100644 index 0000000000000..7b48a9a31f1a3 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsFalse.json @@ -0,0 +1,43 @@ +{ + "Entries": [ + { + "RequestUri": "https://seanmcccanary3.blob.core.windows.net/?restype=account\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Authorization": "Sanitized", + "traceparent": "00-d8df275de8639249b16d276c579e8d2b-bb926aef2d94354d-00", + "User-Agent": [ + "azsdk-net-Storage.Blobs/12.8.0-alpha.20201202.1", + "(.NET 5.0.0; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "7b347465-80f9-73cc-1ed4-f1313f4a8d20", + "x-ms-date": "Wed, 02 Dec 2020 17:11:36 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2020-02-10" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-sku-name,x-ms-account-kind,x-ms-is-hns-enabled,Content-Length,Date,Transfer-Encoding", + "Content-Length": "0", + "Date": "Wed, 02 Dec 2020 17:11:37 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-account-kind": "StorageV2", + "x-ms-client-request-id": "7b347465-80f9-73cc-1ed4-f1313f4a8d20", + "x-ms-is-hns-enabled": "false", + "x-ms-request-id": "e67e35e8-801e-0077-6cce-c80f56000000", + "x-ms-sku-name": "Standard_RAGRS", + "x-ms-version": "2020-02-10" + }, + "ResponseBody": [] + } + ], + "Variables": { + "RandomSeed": "1680189372", + "Storage_TestConfigDefault": "ProductionTenant\nseanmcccanary3\nU2FuaXRpemVk\nhttps://seanmcccanary3.blob.core.windows.net\nhttps://seanmcccanary3.file.core.windows.net\nhttps://seanmcccanary3.queue.core.windows.net\nhttps://seanmcccanary3.table.core.windows.net\n\n\n\n\nhttps://seanmcccanary3-secondary.blob.core.windows.net\nhttps://seanmcccanary3-secondary.file.core.windows.net\nhttps://seanmcccanary3-secondary.queue.core.windows.net\nhttps://seanmcccanary3-secondary.table.core.windows.net\n\nSanitized\n\n\nCloud\nBlobEndpoint=https://seanmcccanary3.blob.core.windows.net/;QueueEndpoint=https://seanmcccanary3.queue.core.windows.net/;FileEndpoint=https://seanmcccanary3.file.core.windows.net/;BlobSecondaryEndpoint=https://seanmcccanary3-secondary.blob.core.windows.net/;QueueSecondaryEndpoint=https://seanmcccanary3-secondary.queue.core.windows.net/;FileSecondaryEndpoint=https://seanmcccanary3-secondary.file.core.windows.net/;AccountName=seanmcccanary3;AccountKey=Kg==;\nseanscope1" + } +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsFalseAsync.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsFalseAsync.json new file mode 100644 index 0000000000000..5b6ae3d39408d --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsFalseAsync.json @@ -0,0 +1,43 @@ +{ + "Entries": [ + { + "RequestUri": "https://seanmcccanary3.blob.core.windows.net/?restype=account\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Authorization": "Sanitized", + "traceparent": "00-6e380dcd9e531644bc22064cae5ec4bb-459bf9c59529e64a-00", + "User-Agent": [ + "azsdk-net-Storage.Blobs/12.8.0-alpha.20201202.1", + "(.NET 5.0.0; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "f6922cdb-a429-f150-5682-71f893699747", + "x-ms-date": "Wed, 02 Dec 2020 17:11:37 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2020-02-10" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Access-Control-Allow-Origin": "*", + "Access-Control-Expose-Headers": "x-ms-request-id,x-ms-client-request-id,Server,x-ms-version,x-ms-sku-name,x-ms-account-kind,x-ms-is-hns-enabled,Content-Length,Date,Transfer-Encoding", + "Content-Length": "0", + "Date": "Wed, 02 Dec 2020 17:11:37 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-account-kind": "StorageV2", + "x-ms-client-request-id": "f6922cdb-a429-f150-5682-71f893699747", + "x-ms-is-hns-enabled": "false", + "x-ms-request-id": "b6a99971-d01e-0008-17ce-c8c0cd000000", + "x-ms-sku-name": "Standard_RAGRS", + "x-ms-version": "2020-02-10" + }, + "ResponseBody": [] + } + ], + "Variables": { + "RandomSeed": "422318522", + "Storage_TestConfigDefault": "ProductionTenant\nseanmcccanary3\nU2FuaXRpemVk\nhttps://seanmcccanary3.blob.core.windows.net\nhttps://seanmcccanary3.file.core.windows.net\nhttps://seanmcccanary3.queue.core.windows.net\nhttps://seanmcccanary3.table.core.windows.net\n\n\n\n\nhttps://seanmcccanary3-secondary.blob.core.windows.net\nhttps://seanmcccanary3-secondary.file.core.windows.net\nhttps://seanmcccanary3-secondary.queue.core.windows.net\nhttps://seanmcccanary3-secondary.table.core.windows.net\n\nSanitized\n\n\nCloud\nBlobEndpoint=https://seanmcccanary3.blob.core.windows.net/;QueueEndpoint=https://seanmcccanary3.queue.core.windows.net/;FileEndpoint=https://seanmcccanary3.file.core.windows.net/;BlobSecondaryEndpoint=https://seanmcccanary3-secondary.blob.core.windows.net/;QueueSecondaryEndpoint=https://seanmcccanary3-secondary.queue.core.windows.net/;FileSecondaryEndpoint=https://seanmcccanary3-secondary.file.core.windows.net/;AccountName=seanmcccanary3;AccountKey=Kg==;\nseanscope1" + } +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsTrue.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsTrue.json new file mode 100644 index 0000000000000..d4be9edd5f87f --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsTrue.json @@ -0,0 +1,41 @@ +{ + "Entries": [ + { + "RequestUri": "https://seannsecanary.blob.core.windows.net/?restype=account\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Authorization": "Sanitized", + "traceparent": "00-af721b3c03328b42a523450f70c617a7-704165437aa3a841-00", + "User-Agent": [ + "azsdk-net-Storage.Blobs/12.8.0-alpha.20201202.1", + "(.NET 5.0.0; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "1c2e1e89-959e-14a1-3394-81f4d8c52010", + "x-ms-date": "Wed, 02 Dec 2020 17:11:37 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2020-02-10" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 02 Dec 2020 17:11:37 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-account-kind": "StorageV2", + "x-ms-client-request-id": "1c2e1e89-959e-14a1-3394-81f4d8c52010", + "x-ms-is-hns-enabled": "true", + "x-ms-request-id": "0d7ba470-101e-008c-7ece-c825ae000000", + "x-ms-sku-name": "Standard_RAGRS", + "x-ms-version": "2020-02-10" + }, + "ResponseBody": [] + } + ], + "Variables": { + "RandomSeed": "1844613876", + "Storage_TestConfigHierarchicalNamespace": "NamespaceTenant\nseannsecanary\nU2FuaXRpemVk\nhttps://seannsecanary.blob.core.windows.net\nhttps://seannsecanary.file.core.windows.net\nhttps://seannsecanary.queue.core.windows.net\nhttps://seannsecanary.table.core.windows.net\n\n\n\n\nhttps://seannsecanary-secondary.blob.core.windows.net\nhttps://seannsecanary-secondary.file.core.windows.net\nhttps://seannsecanary-secondary.queue.core.windows.net\nhttps://seannsecanary-secondary.table.core.windows.net\n68390a19-a643-458b-b726-408abf67b4fc\nSanitized\n72f988bf-86f1-41af-91ab-2d7cd011db47\nhttps://login.microsoftonline.com/\nCloud\nBlobEndpoint=https://seannsecanary.blob.core.windows.net/;QueueEndpoint=https://seannsecanary.queue.core.windows.net/;FileEndpoint=https://seannsecanary.file.core.windows.net/;BlobSecondaryEndpoint=https://seannsecanary-secondary.blob.core.windows.net/;QueueSecondaryEndpoint=https://seannsecanary-secondary.queue.core.windows.net/;FileSecondaryEndpoint=https://seannsecanary-secondary.file.core.windows.net/;AccountName=seannsecanary;AccountKey=Sanitized\n" + } +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsTrueAsync.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsTrueAsync.json new file mode 100644 index 0000000000000..94c5096121359 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/GetAccountInfoAsync_HnsTrueAsync.json @@ -0,0 +1,41 @@ +{ + "Entries": [ + { + "RequestUri": "https://seannsecanary.blob.core.windows.net/?restype=account\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Authorization": "Sanitized", + "traceparent": "00-c388f41add07b14db253736111ae0761-d711ac889bb5374b-00", + "User-Agent": [ + "azsdk-net-Storage.Blobs/12.8.0-alpha.20201202.1", + "(.NET 5.0.0; Microsoft Windows 10.0.19042)" + ], + "x-ms-client-request-id": "d1dc553f-97f2-1916-78d8-7f2ea7b3c1b9", + "x-ms-date": "Wed, 02 Dec 2020 17:11:38 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2020-02-10" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Wed, 02 Dec 2020 17:11:37 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-account-kind": "StorageV2", + "x-ms-client-request-id": "d1dc553f-97f2-1916-78d8-7f2ea7b3c1b9", + "x-ms-is-hns-enabled": "true", + "x-ms-request-id": "1e709d22-201e-0097-65ce-c81bad000000", + "x-ms-sku-name": "Standard_RAGRS", + "x-ms-version": "2020-02-10" + }, + "ResponseBody": [] + } + ], + "Variables": { + "RandomSeed": "396550379", + "Storage_TestConfigHierarchicalNamespace": "NamespaceTenant\nseannsecanary\nU2FuaXRpemVk\nhttps://seannsecanary.blob.core.windows.net\nhttps://seannsecanary.file.core.windows.net\nhttps://seannsecanary.queue.core.windows.net\nhttps://seannsecanary.table.core.windows.net\n\n\n\n\nhttps://seannsecanary-secondary.blob.core.windows.net\nhttps://seannsecanary-secondary.file.core.windows.net\nhttps://seannsecanary-secondary.queue.core.windows.net\nhttps://seannsecanary-secondary.table.core.windows.net\n68390a19-a643-458b-b726-408abf67b4fc\nSanitized\n72f988bf-86f1-41af-91ab-2d7cd011db47\nhttps://login.microsoftonline.com/\nCloud\nBlobEndpoint=https://seannsecanary.blob.core.windows.net/;QueueEndpoint=https://seannsecanary.queue.core.windows.net/;FileEndpoint=https://seannsecanary.file.core.windows.net/;BlobSecondaryEndpoint=https://seannsecanary-secondary.blob.core.windows.net/;QueueSecondaryEndpoint=https://seannsecanary-secondary.queue.core.windows.net/;FileSecondaryEndpoint=https://seannsecanary-secondary.file.core.windows.net/;AccountName=seannsecanary;AccountKey=Sanitized\n" + } +} \ No newline at end of file