使用 .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.
关于帐户类型和 SKU 名称About account type and SKU name
帐户类型:有效的帐户类型包括 BlobStorage
、BlockBlobStorage
、FileStorage
、Storage
和 StorageV2
。Account 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_LRS
、Standard_GRS
、Standard_LRS
和 Standard_RAGRS
。SKU name: Valid SKU names include Premium_LRS
, Standard_GRS
, Standard_LRS
, and Standard_RAGRS
.
检索帐户信息Retrieve account information
以下代码示例检索并显示只读帐户属性。The following code example retrieves and displays the read-only account properties.
若要获取与 Blob 关联的存储帐户类型和 SKU 名称,请调用 GetAccountInfo 或 GetAccountInfoAsync 方法。To get the storage account type and SKU name associated with a blob, call the GetAccountInfo or GetAccountInfoAsync method.
private static async Task GetAccountInfoAsync(string connectStr)
{
try
{
BlobServiceClient blobServiceClient = new BlobServiceClient(connectStr);
// Get the blob's storage account properties.
AccountInfo acctInfo = await blobServiceClient.GetAccountInfoAsync();
// Display the properties.
Console.WriteLine("Account info");
Console.WriteLine($" AccountKind: {acctInfo.AccountKind}");
Console.WriteLine($" SkuName: {acctInfo.SkuName}");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"HTTP error code {ex.Status}: {ex.ErrorCode}");
Console.WriteLine(ex.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
- API 参考文档API reference documentation
- 库源代码Library source code
- 版本 11.x 的包 (NuGet)Package (NuGet) for version 11.x
- 版本 12.x 的包 (NuGet)Package (NuGet) for version 12.x
.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.