Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.35k stars 4.66k forks source link

[BUG] BlobErrorCode type doesn't contain BlobAccessTierNotSupportedForAccountType #32914

Open Archomeda opened 1 year ago

Archomeda commented 1 year ago

Library name and version

Azure.Storage.Blobs 12.14.1

Describe the bug

Azure.Storage.Blobs.Models.BlobErrorCode doesn't contain the BlobAccessTierNotSupportedForAccountType error code that occurs when setting an AccessTier when writing a new blob to a V1 storage account.

Expected behavior

Azure.Storage.Blobs.Models.BlobErrorCode contains BlobAccessTierNotSupportedForAccountType

Actual behavior

Azure.Storage.Blobs.Models.BlobErrorCode doesn't contain BlobAccessTierNotSupportedForAccountType

Reproduction Steps

Run the following code with a custom file path and source data (or stream) and observe that the request fails with a RequestFailedException and the error code BlobAccessTierNotSupportedForAccountType.

using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;

var uploadOptions = new BlobUploadOptions
{
    AccessTier = AccessTier.Hot
};
var blob = new BlobClient(...);
await blob.UploadAsync(..., options: uploadOptions);

Environment

No response

ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

navba-MSFT commented 1 year ago

@Archomeda Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

navba-MSFT commented 1 year ago

@Archomeda I am able to run the below sample code successfully and it worked just fine. Could you please let us know the Storage Account kind ? This is present in the Azure Storage portal blade within the configuration section as shown below:

image

The Access Tiers are supported for general-purpose v2 or Blob Storage account types. Please check the type of your storage account. I am guessing you might be using GpV1 storage account which doesn't support Access Tier.

Sample Code:

            string connectionString = "Storage Account - Connection String";

            // Create a BlobServiceClient object which will be used to create a container client
            BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

            //Create a unique name for the container
            string containerName = "MyContainerName" + Guid.NewGuid().ToString();

            // Create the container and return a container client object
            BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);

            // Create a local file in the ./data/ directory for uploading and downloading
            string localPath = "./data/";
            string fileName = "MyBlob.txt";
            string localFilePath = Path.Combine(localPath, fileName);

            // Write text to the file
            await File.WriteAllTextAsync(localFilePath, "HelloWorld");

            // Get a reference to a blob
            BlobClient blobClient = containerClient.GetBlobClient(fileName);

            var uploadOptions = new BlobUploadOptions
            {
                AccessTier = AccessTier.Hot
            };

            await blobClient.UploadAsync(localFilePath, options: uploadOptions);

More Info here.

Archomeda commented 1 year ago

@navba-MSFT The sample is just about reproducing that ErrorCode when writing to V1 storage accounts, as I've mentioned in the bug description. That V1 storage accounts do not support AccessTiers, is understandable, but the BlobErrorCode type should at least contain that error code definition as well.

navba-MSFT commented 1 year ago

@Archomeda Thanks for clarifying this. We will update our documentation to include this information.

navba-MSFT commented 1 year ago

@Archomeda PR to update the docs is now merged https://github.com/Azure/azure-sdk-for-net/pull/32968. See the other thread https://github.com/Azure/azure-sdk-for-net/issues/32910

Archomeda commented 1 year ago

@navba-MSFT This is a different issue. This is about the BlobErrorCode class missing the BlobAccessTIerNotSupportedForAccountType string, and not about the documentation not clarifying that the AccessTier can be null.

navba-MSFT commented 1 year ago

Thanks for clarifying. I am adding service team to look into this.

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details
### Library name and version Azure.Storage.Blobs 12.14.1 ### Describe the bug Azure.Storage.Blobs.Models.BlobErrorCode doesn't contain the BlobAccessTierNotSupportedForAccountType error code that occurs when setting an AccessTier when writing a new blob to a V1 storage account. ### Expected behavior Azure.Storage.Blobs.Models.BlobErrorCode contains BlobAccessTierNotSupportedForAccountType ### Actual behavior Azure.Storage.Blobs.Models.BlobErrorCode doesn't contain BlobAccessTierNotSupportedForAccountType ### Reproduction Steps Run the following code with a custom file path and source data (or stream) and observe that the request fails with a RequestFailedException and the error code BlobAccessTierNotSupportedForAccountType. ```cs using Azure.Storage.Blobs.Models; using Azure.Storage.Blobs.Specialized; var uploadOptions = new BlobUploadOptions { AccessTier = AccessTier.Hot }; var blob = new BlobClient(...); await blob.UploadAsync(..., options: uploadOptions); ``` ### Environment _No response_
Author: Archomeda
Assignees: -
Labels: `Storage`, `Service Attention`, `Client`, `customer-reported`, `feature-request`, `needs-team-attention`
Milestone: -
navba-MSFT commented 1 year ago

@xgithubtriage Could you please look into this request ?

seanmcc-msft commented 8 months ago

This is a simple fix, we should take this.