Azure / azure-storage-cpplite

Lite version of C++ Client Library for Microsoft Azure Storage
MIT License
25 stars 43 forks source link

The value for one of the HTTP headers is not in the correct format #79

Closed majumd closed 4 years ago

majumd commented 4 years ago

Hi,

I am using the cpp lite version of Azure Storage Client Library. I am using v0.3 version. I am connecting to a Dell Azure Stack Hub of version IdentitySystem : AzureAD OemVersion : 2.1.1908.3 StampVersion : 1.2002.19.73

Can the v0.3 version connect to the above Azure Stack Hub versions? Am i using the right version of the client library?

std::shared_ptr<storage_credential> credential = std::make_shared<shared_key_credential>(account_name, account_key);
std::shared_ptr<storage_account> account = std::make_shared<storage_account>(account_name, credential, /* use_https */ true, blob_endpoint);
auto bC = std::make_shared<blob_client>(account, 16);
std::string containerName = "fs-magicians-container1";
std::string blobName = "nbu-nagini-unmanaged-disk-v2.ee86dfba-2320-451f-8efd-af7ff9b341c4.screenshot.bmp";
bool exists = true;
blob_client_wrapper bc(bC);
exists = bc.container_exists(containerName);
if (exists)
{
    std::cout << "Success: The container exists";
}
else
{
    std::cout << "Failed to find container" << errno << std::endl;
}
Jinming-Hu commented 4 years ago

@majumd Hi, we haven't officially supported Azure Storage Hub yet, but cpplite sdk should be able to work with it.

Can you provide some information so that we can further investigate?

  1. What does the endpoint look like for Azure Stack Hub?
  2. What kind of authentication are you using?
  3. Which HTTP header isn't in the correct format? What is it supposed to be?

In addition, please avoid using that blob_client_wrapper and always stick to blob_client like in this sample.

majumd commented 4 years ago

Hi, I have modified code as per sample given by you to use blob_client but still it gives error. "The value of one of the HTTP headers is not in correct format"

majumd commented 4 years ago

I have used the following std::string account_name = "fsmagicstorageacc1"; std::string account_key = "xxxxQ=="; // Storage account key if using shared key auth std::string blob_endpoint = "fsmagicstorageacc1.blob.dazs1.wwtrrratc.com/";

The names are correct names. I have given just for representation. The key used above is the user access key obtained by logging into portal. Dashboard > Storage accounts > - Access keys I used key1 in the user access keys. Use access keys to authenticate your applications when making requests to this Azure storage account. ...

Jinming-Hu commented 4 years ago

@majumd can you also share the error response body?

majumd commented 4 years ago

This is the only HTTP header response which is being returned. HTTP/1.1 400 The value for one of the HTTP headers is not in the correct format.

It would have been nice if it could return which header is not in correct format.

Jinming-Hu commented 4 years ago

Hi @majumd, the request header looks completely normal and I believe it's going to work if running against Azure Storage server.

This C++ sdk is targeted at Azure Storage server. Any other kind of server including Azure Stack is supposed to expose exactly the same interface as Azure Storage if they want to be able to work with client sdk. So I think your request failed because Azure Stack server behaves differently.

snehalw777 commented 4 years ago

Hi, For the error specified by @majumd, I am getting the error response body as :

Code : InvalidHeaderValue

Message : The value for one of the HTTP headers is not in the correct format. RequestId:6abd80a3-3c81-0a33-6566-4c83d6bd9132 Time:2020-06-19T12:57:25.5124783Z

HeaderName : x-ms-version

HeaderValue : 2018-11-09

From the error body it seems that, storage service version "2018-11-09" is used while getting the container properties. Does this version is supported by cpp lite version of Azure Storage client library(v0.3 version)?

Jinming-Hu commented 4 years ago

Hi @snehalw777 , seems your Azure Stack doesn't support this API version. Can you edit here and try 2019-02-02, 2019-07-07 and 2019-10-10?

If those don't work, you can also try some older versions like 2018-03-28, 2017-11-09, 2017-07-29.

snehalw777 commented 4 years ago

Thanks for the reference @JinmingHu-MSFT It worked with older API version.

Jinming-Hu commented 4 years ago

@snehalw777 Okay, I think you can use the old API version. But 2018-11-09 is an API version with breaking changes, which means that there might be one or more API in this sdk that cannot function properly if you just change the API version. So Please do use test cases to cover those API you're going to use to make sure everything works fine.

majumd commented 4 years ago

I am closing this issue because this lite version v0.3 started working using API version 2017-11-09 on an Azure Stack Hub setup of version 2002(latest version).