I am running this code
require_once 'windowsazure\windowsazure.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
try {
$connectionString = "DefaultEndpointsProtocol=http;AccountName=xxx;AccountKey=yyyy";
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// Set container metadata
$createContainerOptions->addMetaData("key1", "value1");
$createContainerOptions->addMetaData("key2", "value2");
// List blobs.
$blob_list = $blobRestProxy->listBlobs("mycontainer");
$blobs = $blob_list->getBlobs();
foreach($blobs as $blob)
{
echo $blob->getName().": ".$blob->getUrl()."<br />";
}
// Create container.
$blobRestProxy->createContainer("phpcontainer", $createContainerOptions);
}
catch(ServiceException $e) {
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code . ": " . $error_message . "<br/>";
}
However, it will report the following error
ServiceException encountered. 400: Fail: Code: 400 Value: One of the request inputs is out of range. details (if any): OutOfRangeInputOne of the request inputs is out of range. RequestId:xxxxxx Time:2015-05-13T08:47:18.0943278Z
when it came to the first line of sending request to Azure storage
$blob_list = $blobRestProxy->listBlobs("mycontainer");
I've installed the dependency of Azure PHP SDK via pear (http_request2, mail_mime
, mail_mimedecode
) and put them at default position c:\php\pear\
And the connectionstring
I used should be a correct one.
What I have missed?
Thanks