So I have a function that simply downloads text from blob storage every 10 minutes and checks for a result. This function can run for days. But it often (roughly every day) fails before finishing with the following error.
Caused by: com.microsoft.azure.storage.StorageException: The condition specified using HTTP conditional header(s) is not met.
My code is pretty simple.
public String downloadTextBlob(CloudBlobDirectory dir, String filename) {
try {
return dir.getBlockBlobReference(filename).downloadText();
} catch (StorageException | IOException | URISyntaxException e) {
throw new WorkbenchRuntimeException(e.getMessage(), e);
}
}
I the same issue posted here, and I was interested in the answer which talked about using an OperationContext to fix the issue. But the question wasn't on Java, and the answer didn't really explain what it was actually doing.
Here's the proposed solution (non java code)
OperationContext context = new OperationContext();
context.SendingRequest += (sender, e) => {
e.Request.Headers["if-match"] = "*";
};
Can anyone explain what this is actually doing? And maybe how I can replicate this in Java, I notice there is an OperationContext in the Java azure storage sdk, and that I can call the .downloadText() with an operation context as a parameter. I'm just not sure what to do with OperationContext.