Akos Lukacs
Akos Lukacs

Reputation: 2047

BlobClient - What is the recommended way to check if my upload was successfull?

The Azure blob client's Upload method returns a Response<BlobContentInfo>.

If the upload throws an exception, than something is wrong, that's clear. Failure cases, like bad connection string or no internet connection does throw an exception. And it retries by default.

But if I do get a Response back, can still something be wrong?

On the BlobContentInfo I see no indicator of any error.

The Response has a GetRawResponse method, and there is a IsError bool flag on that, and a Status for HTTP status code. But no specific description if something goes wrong.

Maybe check for IsError, and try to log the response, if it's true, and assume it did work, if there is no error. And check the ContentHash I guess.

Upvotes: 1

Views: 1752

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136306

But if I do get a Response back, can still something be wrong?

No. It would mean what you were trying to upload got uploaded successfully.

If your upload fails, the method will raise an exception of type RequestFailedException.

Upvotes: 2

Related Questions