- Include following files:
use WindowsAzure\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Common\ServiceException;
require_once 'azure/vendor/autoload.php';
- Get the Credentials
$azureUserName='XXXXXXXXXXXX';
$azureKey='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$containter='XXXXXXXXX';
-
Set the Credentias
$connectionString = "DefaultEndpointsProtocol=http;AccountName={$azureUserName};AccountKey={$azureKey}";
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
-
Upload the File in Azure
$blobName='textFile.txt';
$content = fopen('../data/test6.txt', "r");
try {
$blobRestProxy->createBlockBlob($containter, $blobName, $content);
echo 'Uploaded successfully';
}
catch(ServiceException $e){
$code = $e->getCode();
$e->getMessage();
}