I have installed today Azure Client Libraries using direction on this page https://learn.microsoft.com/en-us/azure/storage/blobs/storage-php-how-to-use-blobs#create-a-php-application
but i am getting below error.
400: Fail:
Code: 400
Value: The value for one of the HTTP headers is not in the correct format.
details (if any): InvalidHeaderValueThe value for one of the HTTP headers is not in the correct format. RequestId:f0046f48-001e-0046-22ab-2823fb000000 Time:2017-09-08T14:06:55.1682373Zx-ms-version2012-02-12.
My Code is as below:
require_once 'vendor/autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;
use MicrosoftAzure\Storage\Common\ServiceException;
$connectionString = "DefaultEndpointsProtocol=http;AccountName=MyAccountName;AccountKey=4cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==";
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
//create container
$createContainerOptions = new CreateContainerOptions();
// private to the account owner.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// Set container metadata.
$createContainerOptions->addMetaData("category", "my first category data");
try {
// Create container.
$blobRestProxy->createContainer("test", $createContainerOptions);
}
catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/library/azure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo "Erro in create container <br><br>";
echo $code.": ".$error_message."<br />";
//print_r($e);
}
in above code i got "Class not found" error so updated code as below:
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
after above change in code, "class not found" error solved and also i checked that connection string is working well but getting error, which described in start of my question.
Thanks :)
There is Azure SDK Version problem so you can download SDK v0.5.5 from my this blog and also can work on your PHP 5.4
http://mytechdevelopment.blogspot.com/2018/01/azure-sdk-055-for-php-54-or-igher.html