Sign in

Upload image data in the cloud with Azure Storage

Step on how to upload images to blob storage from web app

You can use either Azure Powershell or Azure portal to do the following steps

Create a resource group

Create a storage account

Create Blob storage containers

Create an App service plan

Create the web App

Configure web app setting to store storage account credentials

Use the following method to upload the image to Blob Storage

public static async Task<bool> UploadFileToStorage(Stream fileStream, string fileName,
AzureStorageConfig _storageConfig)
{
// Create a URI to the blob
Uri blobUri = new Uri(“https://” +
_storageConfig.AccountName +
“.blob.core.windows.net/” +
_storageConfig.ImageContainer +
“/” + fileName);

// Create StorageSharedKeyCredentials object by reading
// the values from the configuration (appsettings.json)
StorageSharedKeyCredential storageCredentials =
new StorageSharedKeyCredential(_storageConfig.AccountName, _storageConfig.AccountKey);

// Create the blob client.
BlobClient blobClient = new BlobClient(blobUri, storageCredentials);

// Upload the file
await blobClient.UploadAsync(fileStream);

return await Task.FromResult(true);
}

This should assist you in uploading images from any application.
Please provide feedback and share this article if you found it useful.