Azure / azure-storage-cpp

Microsoft Azure Storage Client Library for C++
http://azure.github.io/azure-storage-cpp
Apache License 2.0
132 stars 147 forks source link

Question: is there a way to get the location (region) of the storage via the SDK? #311

Closed kiril-kirov closed 4 years ago

kiril-kirov commented 4 years ago

Hi,

Given the fact a storage account is associated with a specific region/location, is there a way to retrieve this region, based on the provided storage credentials? (geo replication is not enabled, so no secondary location)

I think I may need to get the storage account properties, but I couldn't find an easy way to do so (https://docs.microsoft.com/en-us/rest/api/storagerp/storageaccounts/getproperties)

Thanks, Kiril

Jinming-Hu commented 4 years ago

This azure-storage-cpp sdk supports Blob/File/Table/Queue services. Operations on storage account don't fall into these categories. Plus these operations use another kind of authentication which isn't supported by cpp sdk.

I recommend that you use Azure Portal or Azure PowerShell to get storage account properties.

kiril-kirov commented 4 years ago

So, we can't even make custom REST request (using CPP REST SDK / Casablanca), because the account permissions won't have access to such information? Is there any way to retrieve this information using C/C++?

Jinming-Hu commented 4 years ago

Of course you can get the storage account properties via REST request, as long as you have the authorization. In this reference it states that this API only supports OAuth2.

So, what you need to do is, get the OAuth2 token, and add it to HTTP request header like this:

Authorization: bearer YOUR_OAUTH_TOKEN

The problem is this access token usually has different privileges from the one we use to upload/download data. This is why we don't want to add this feature into our storage sdk.

kiril-kirov commented 4 years ago

Yeah, I saw that request and was wondering where's the catch. Seems like OAuth2 is the part, I've missed.

Okay, thanks a lot, that was very valuable information, appreciated! I believe we can close the issue.