I have the following code:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("AzureWebJobsStorage"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("images");
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(filename);
using (var stream = new MemoryStream(imageBytes))
{
blockBlob.Properties.ContentType = contentType;
blockBlob.Metadata.Add("MyMetadataProperty1", "MyMetadataValue1");
blockBlob.Metadata.Add("MyMetadataProperty2", "MyMetadataValue2");
blockBlob.Metadata.Add("MyMetadataProperty3", "MyMetadataValue3");
blockBlob.Metadata.Add("MyMetadataProperty", "MyMetadataValue4");
// await blockBlob.SetMetadataAsync(); // Microsoft.WindowsAzure.Storage: The specified blob does not exist.
await blockBlob.UploadFromStreamAsync(stream);
}
I can't setup metadata on the upload time.
If I call await blockBlob.SetMetadataAsync();
before UploadFromStreamAsync()
, I get error: Microsoft.WindowsAzure.Storage: The specified blob does not exist.
I found some articles in the Internet that I can do that: here and here.
Library that I use:
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
Any ideas why I have this error?