RichyRoo
RichyRoo

Reputation: 430

How do I write to a Blob when UseDevelopmentStorage=true?

Im writing a stream to a blob:

                var connectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage");
                BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
                BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(FunctionNames.BlobContainer);
                BlobClient blobClient = containerClient.GetBlobClient(fileName);

                using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(rawReport)))
                {
                    ms.Position = 0;
                    var response = await blobClient.UploadAsync(ms);
                }

My local config contains this line:

    "AzureWebJobsStorage": "UseDevelopmentStorage=true",

I would expect the blob to be written to my local storage but its not happening. No exception is thrown, the response object is populated with the sort of data one would expect from a sucessfully written blob. But the blob isnt there!

Works fine when I put an Azure storage account connection string in the config. Is there another way to pass this connection string, or another format I am supposed to be using in this case? I am using VS 2019 16.7.4 , Azure Storage Emulator 1.15.1 and Azure.Storage.Blobs 12.5.1

Upvotes: 1

Views: 2541

Answers (1)

Jens Stragier
Jens Stragier

Reputation: 223

When using "UseDevelopmentStorage=true" - the data will be written to a local storage instance (db).

Check (localdb)\MSSQLLocalDB or start AzureStorageEmulator.exe to see more information about your local instance.

Upvotes: 2

Related Questions