1

I download a blob from storage account to local drive using the following:

 $context = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey 
 Get-AzStorageBlobContent -Container $containerName -Blob $blobName -Destination $localPath -Context $context

The $context is returned but when it runs the line Get-AzStorageBlobContent with the parameters i get an error:

    Get-AzStorageBlobContent : The condition specified using HTTP conditional header(s) is not met. HTTP Status Code: 412 - HTTP Error Message: The condition specified using HTTP conditional header(s) is not met.

But the file still downloads . How can i fix this error ?

1 Answer 1

0

Get-AzStorageBlobContent : The condition specified using HTTP conditional header(s) is not met. HTTP Status Code: 412 - HTTP Error Message: The condition specified using HTTP conditional header(s) is not met.

According to this SO-answer by Gaurav Mantri.

When a write operation is done on a blob, the ETag of the Blob is reset, let's say 0x8CDA1BF0593B660. And, before it is triggered(with ETag value 0x8CDA1BF0593B660), the blob is updated by another service, and its ETag is changed to 0x8CDA1BF0593B661.

Now, the etag value is changed that might be causing the above error, you can use the -force parameter to Overwrites an existing file without confirmation.

Command:

$storageAccountName="venkat326123"
$storageAccountKey="T3cxxxxxxp4Wu2+AStD9nyWw=="
$containerName="test"
$blobName="data.png"
$localPath="C:\Users\xxxx\Documents\folder1\sample.png"

$context = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
Get-AzStorageBlobContent -Container $containerName -Blob $blobName -Destination $localPath -Context $context -Force

Always use the -Force parameter carefully, as it can cause data loss by overwriting files without asking first.

Output:

   AccountName: venkat326123, ContainerName: test

Name                 BlobType  Length          ContentType                    LastModified         AccessTier SnapshotTime                 IsDeleted  VersionId                     
----                 --------  ------          -----------                    ------------         ---------- ------------                 ---------  ---------                     
data.png             BlockBlob xxxxxx            application/octet-stream       2024-10-07 08:21:59Z Hot                                     False        
          

enter image description here

Reference:

Sign up to request clarification or add additional context in comments.

7 Comments

I added the force , same error .. ?
Have you checked? Whether etag is changing in your scenario?
etag ? what is that and how can i check ?
Have you check attached referenced link.
this one SO-answer
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.