Get Azure premium storage account properties

2019-07-11 18:57发布

问题:

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. The extended error information contains: Value for one of the query parameters specified in the request URI is invalid. (QueryParameterName=restype QueryParameterValue=service) This method works fine with other standard (classic) accounts.

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?

回答1:

GetServiceProperties makes Get Blob Service Properties REST API call which is used to get CORS and Storage Analytics setting. As both CORS and Storage Analytics are not supported for Premium storage account, you're getting this error.

But how can I use CloudBlobClient for work with this type of storage account?

You can use CloudBlobClient for all supported operations on a Premium Storage Account. For example, you can create a reference for a Blob Container and create a container using that.