Uploading blockblob and setting contenttype

Actually you don't have to call SetProperties method. In order to set content type while uploading the blob, just set the ContentType property before calling the upload method. So your code should be:

// Save image
CloudBlockBlob blockBlob = container.GetBlockBlobReference("blah.jpg");
blockBlob.Properties.ContentType = "image/jpg";
blockBlob.UploadFromByteArray(byteArrayThumbnail, 0, byteArrayThumbnail.Length);

and that should do the trick.


After you make any changes to Properties, you have to make a call to CloudBlockBlob.SetProperties() to actually save those changes.

Think of it as something similar to LINQ-to-Entities. You can make any changes you want to your local object, but until you call SaveChanges(), nothing is actually saved.


Using the new SDK Azure.Storage.Blobs

BlobHttpHeaders blobHttpHeaders = new BlobHttpHeaders();
blobHttpHeaders.ContentType = "image/jpg";
blobClient.SetHttpHeaders(blobHttpHeaders);

Unfortunately, none of the answers provided here is currently working for the latest SDK (12.x.+)

With the latest SDK, the content type should be set via BlobHttpHeaders.

var _blobServiceClient = new BlobServiceClient("YOURCONNECTIONSTRING");

var containerClient = _blobServiceClient.GetBlobContainerClient("YOURCONTAINERNAME");

var blob = containerClient.GetBlobClient("YOURFILE.png");

var blobHttpHeader = new BlobHttpHeaders();

blobHttpHeader.ContentType = "image/png";

var uploadedBlob = await blob.UploadAsync(YOURSTREAM, blobHttpHeader);