I have large number of image files on my server (about 900,000), and I'm using Azure Client Library for PHP to make a loop and upload my files to Azure Blob Storage. My upload script ran well for about 2 day, and then suddenly stoped and output below error.
Oct 19 01:28:14 ik1-315-17878 php: PHP Fatal error: Uncaught exception 'MicrosoftAzure\Storage\Common\Exceptions\ServiceException' with message 'Fail:#012Code: 403#012Value: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.#012details (if any):
AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.#012RequestId:e7f247d6-001e-0022-142e-48abcc000000#012Time:2017-10-18T16:28:14.4980791ZRequest date header too old: 'Wed, 18 Oct 2017 16:12:27 GMT'.' in /home/t-matsumoto/GAZOU/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php:486#012Stack trace:#012#0 /home/t-matsumoto/GAZOU/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php(404): MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::throwIfError(Object(GuzzleHttp\Psr7\Respon in /home/t-matsumoto/GAZOU/vendor/microsoft/azure-storage/src/Common/Internal/ServiceRestProxy.php on line 486
I've searched about the cause, and it's likely because timestamp when my script made that request was too old comparing to timestamp when Azure received the request. According to the error message above, time of making request is "Wed, 18 Oct 2017 16:12:27 GMT", and time of receiving request is "2017-10-18T16:28:14.4980791Z" (about 15 minutes late). But what I still don't understand is that why my script had run for a while with no error, and then the error occurred suddenly. Can anyone explain to me that phenomenon and solution to make my script run stably with no error.
My php script looks like below
require_once 'vendor/autoload.php'; use MicrosoftAzure\Storage\Common\ServicesBuilder; use MicrosoftAzure\Storage\Common\ServiceException; $connectionString = "DefaultEndpointsProtocol=http;AccountName=<accountNameHere>;AccountKey=<accountKeyHere>"; // Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); foreach ($myListFiles as $filename) { $content = fopen($filename, "r"); $blob_name = "myblob"; //Upload blob $blobRestProxy->createBlockBlob("mycontainer", $blob_name, $content); } I got uploading sample script from this link https://learn.microsoft.com/en-us/azure/storage/blobs/storage-php-how-to-use-blobs