Search code examples
pythonazureazure-blob-storageazure-sdkazure-sdk-python

Azure python SDK - AzureHttpError: The condition specified using HTTP conditional header(s) is not met


I'm trying to download a large VHD file (30GB) from Azure Blob Storage using the following code:

blob_service.get_blob_to_path('vhds', '20161206092429.vhd', '20161206092429.vhd')

where the first parameter is the container name, the second the blob name, and the third the local file/path where it will be saved. This 30GB download was working normally, but all of a sudden I started receiving this error:

AzureHttpError: The condition specified using HTTP conditional header(s) is not met. ConditionNotMetThe condition specified using HTTP conditional header(s) is not met. RequestId:88b6ac24-0001-0001-5ec0-4f490d000000 Time:2016-12-06T12:57:13.5389237Z

Download now runs OK for some random time: sometimes really short time, and sometimes long time. Even up to 9 or 10GB of the full 30GB download.

According to this questions:

Azure Blob: "The condition specified using HTTP conditional header(s) is not met"

304: The condition specified using HTTP conditional header(s) is not met

It seems to be a race condition, but that doesn't help much to solve the issue without diving in and deal with the SDK code. Any suggestions on what can be causing this, as the download was working previously? Maybe an outage on Azure cloud?


Solution

  • As a VHD changes, its related ETag will change. Once this happens, a file-copy operation will no longer be valid. I believe this is what you're seeing via your call to blob_service.get_blob_to_path(), since your vhd is being used with a running VM. And... even if the vm is idle - a running OS is never really idle - there are always some background operations, which likely write to disk.

    Not that it will ensure a successful file-copy operation, but you'd need to shut down the VM first before initiating a copy.

    Alternatively, you can make a snapshot of the VHD and then do a copy via the snapshot instead of the original vhd (which would then let you continue to use your vhd during the copy operation).