Get Azure premium storage account properties

橙三吉。 提交于 2019-12-24 01:46:31

问题


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.



来源:https://stackoverflow.com/questions/37521092/get-azure-premium-storage-account-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!