使用 .NET 获取存储帐户类型和 SKU 名称Get storage account type and SKU name with .NET

本文介绍如何使用用于 .NET 的 Azure 存储客户端库获取 Blob 的 Azure 存储帐户类型和 SKU 名称。This article shows how to get the Azure Storage account type and SKU name for a blob by using the Azure Storage client library for .NET.

从版本 2018-03-28 开始,服务版本上提供帐户信息。Account information is available on service versions beginning with version 2018-03-28.

关于帐户类型和 SKU 名称About account type and SKU name

帐户类型:有效的帐户类型包括 BlobStorageBlockBlobStorageFileStorageStorageStorageV2Account type: Valid account types include BlobStorage, BlockBlobStorage, FileStorage, Storage, and StorageV2. Azure 存储帐户概述提供详细信息,包括对各种存储帐户的说明。Azure storage account overview has more information, including descriptions of the various storage accounts.

SKU 名称:有效的 SKU 名称包括 Premium_LRSStandard_GRSStandard_LRSStandard_RAGRSSKU name: Valid SKU names include Premium_LRS, Standard_GRS, Standard_LRS, and Standard_RAGRS.

检索帐户信息Retrieve account information

若要获取与 Blob 关联的存储帐户类型和 SKU 名称,请调用 GetAccountPropertiesGetAccountPropertiesAsync 方法。To get the storage account type and SKU name associated with a blob, call the GetAccountProperties or GetAccountPropertiesAsync method.

以下代码示例检索并显示只读帐户属性。The following code example retrieves and displays the read-only account properties.

private static async Task GetAccountInfoAsync(CloudBlob blob)
{
    try
    {
        // Get the blob's storage account properties.
        AccountProperties acctProps = await blob.GetAccountPropertiesAsync();

        // Display the properties.
        Console.WriteLine("Account properties");
        Console.WriteLine("  AccountKind: {0}", acctProps.AccountKind);
        Console.WriteLine("      SkuName: {0}", acctProps.SkuName);
    }
    catch (StorageException e)
    {
        Console.WriteLine("HTTP error code {0}: {1}",
                            e.RequestInformation.HttpStatusCode,
                            e.RequestInformation.ErrorCode);
        Console.WriteLine(e.Message);
        Console.ReadLine();
    }
}

使用 .NET 进行开发的资源Resources for development with .NET

下面的链接为使用适用于 .NET 的 Azure 存储客户端库的开发人员提供了有用的资源。The links below provide useful resources for developers using the Azure Storage client library for .NET.

Azure 存储通用 APIAzure Storage common APIs

Blob 存储 APIBlob storage APIs

.NET 工具.NET tools

后续步骤Next steps

了解可以通过 Azure 门户和 Azure REST API 在存储帐户上执行的其他操作。Learn about other operations you can perform on a storage account through the Azure portal and the Azure REST API.