简体   繁体   English

获取 Azure 高级存储帐户属性

[英]Get Azure premium storage account properties

I am trying to get premium storage account (classic) properties using next method:我正在尝试使用下一个方法获取高级存储帐户(经典)属性:

public ServiceProperties GetStorageAccountProperties(string accountName, string accountKey)
    {
        var connectionString = string.Format("DefaultEndpointsProtocol=http;AccountName={0};AccountKey={1};", accountName, accountKey);
        var account = CloudStorageAccount.Parse(connectionString);
        CloudBlobClient bloblClient = account.CreateCloudBlobClient();
        return bloblClient.GetServiceProperties();
    }

But, it throws a StorageException: The remote server returned an error: (400) Bad Request.但是,它会抛出 StorageException:远程服务器返回错误:(400) 错误请求。 The extended error information contains: Value for one of the query parameters specified in the request URI is invalid.扩展错误信息包含: 请求 URI 中指定的查询参数之一的值无效。 (QueryParameterName=restype QueryParameterValue=service) This method works fine with other standard (classic) accounts. (QueryParameterName=restype QueryParameterValue=service) 此方法适用于其他标准(经典)帐户。

Perhaps, it's because of the limitations of the premium storage account.也许,这是因为高级存储帐户的限制。 But how can I use CloudBlobClient for work with this type of storage account?但是如何使用 CloudBlobClient 来处理这种类型的存储帐户?

GetServiceProperties makes Get Blob Service Properties REST API call which is used to get CORS and Storage Analytics setting. GetServiceProperties进行Get Blob Service Properties REST API 调用,该调用用于获取CORSStorage Analytics设置。 As both CORS and Storage Analytics are not supported for Premium storage account, you're getting this error.由于Premium存储帐户不支持CORSStorage Analytics ,因此您会收到此错误。

But how can I use CloudBlobClient for work with this type of storage account?但是如何使用 CloudBlobClient 来处理这种类型的存储帐户?

You can use CloudBlobClient for all supported operations on a Premium Storage Account.您可以将CloudBlobClient用于高级存储帐户上所有受支持的操作。 For example, you can create a reference for a Blob Container and create a container using that.例如,您可以为Blob Container创建一个引用并使用它创建一个容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM