This function is called automatically when a new file (specifically, an image) is uploaded to the uploads container in your Azure Blob Storage account.
Image Processing
- Loads the image using ImageSharp.
- Resizes it to 200x200 pixels.
- Converts the image to JPEG format.
- Uploads the processed image to a separate container named processed-images.
Create container upload at Azure Blob Storage
- Go to Azure Portal.
- Open your Storage Account.
- In the left sidebar, click on "Containers" under Data storage.
- Click "+ Container".
- Enter uploads as the name.
- Set Public access level to Private (recommended).
- Click "Create".
Upload Image at Azure Blob
using Azure.Storage.Blobs;
using System.IO;
using System.Threading.Tasks;string connectionString = "your-storage-connection-string";
string containerName = "uploads";
string localFilePath = "C:\\images\\sample.jpg";
string blobName = Path.GetFileName(localFilePath);var blobServiceClient = new BlobServiceClient(connectionString);
var blobContainerClient = blobServiceClient.GetBlobContainerClient(containerName);
await blobContainerClient.CreateIfNotExistsAsync();
var blobClient = blobContainerClient.GetBlobClient(blobName);// Upload the file
await blobClient.UploadAsync(localFilePath, overwrite: true);