I am a junior front-end developer, and I got a task where I have to take an Azure Blobs Container
lets call it "thumbnails" , loop through and display it on the screen using .Net 6
.
Basically, I have to make an image gallery in Dotnet 6 that takes the images from the Blob Container with DotNet6
, add it to the View (MVC)
and list it with AngularJS
but many of my attempts has failed.
Made a small example in case if it is not clear what I want to achieve:
My questions are:
- How can I take data from Azure Storage with
.net 6
? - How can I create an array from it and pass it to the
View
?
2
Answers
In MVC
Controller:
Model:
appsetting.json: Add Connectionstring data that you can find it the Azure portal, with the name of AConnectionString
View:
See Sample: https://github.com/Azure-Samples/storage-blobs-dotnet-webapp
you need to use the nugget Azure.Storage.Blobs. This package exposes many methods you can utilise.
import the
using System.Linq.Async
for this to work.Check the official docs to see more details on constructing the blobContainer.
You can extract the
base64 string
value from the blobs and bind it in the UI directly.