Zahmi Zuhair I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!
Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer. Accepted answers show up at the top, resulting in improved discoverability for others.
Issue: Customer has enabled on-upload malware scanning for Azure blob storage. Every time a file is uploaded via Storage REST API, it scans the file and store the results under Blob Index Tags as below.
When the trying to retrieve this scan results that are under Blob index tags via REST API with the below PHP curl request, it fails.
$accountName = "xxxxx";
$containerName = "xxxx";
$blobName = "xxxxx";
$storageAccountKey = "xxxxx";
$url = "https://$accountName.blob.core.windows.net/$containerName/$blobName?index";
$date = gmdate('D, d M Y H:i:s \G\M\T');
$version = "2019-12-12";
$stringtosign = "GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:". $date . "\nx-ms-version:".$version."\n/".$accountName."/".$containerName."/".$blobName;
$signature = 'xxxxxxx';
$ch = curl_init();
curl_setopt ( $ch, CURLOPT_URL, $url);
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($ch);
print_r($response);
However, the above code without "?index" in the URL works fine.
Error Message: "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature."
Cause: Missing the correct operation in the URL (?comp=tags
) which indicates to Azure Storage that you are making a request to get the tags associated with the blob.
Solution: You need to add "?comp=tags" in the URL and create the signature from it.
Final $strintosign is as below.
$url = "https://$accountName.blob.core.windows.net/$containerName/$blobName?comp=tags";
$stringtosign = "GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:". $date . "\nx-ms-version:".$version."\n/".$accountName."/".$containerName."/".$blobName."\ncomp:tags";