---
title: "How to Upload Files to Azure Blob Storage using Azure.Storage.Blobs in ASP.NET Core?"  
description: "How to Upload Files to Azure Blob Storage using Azure.Storage.Blobs in ASP.NET Core?"  
author: "Pedro Araez"  
published: 2026-09-07  
updated: 2026-09-07  
canonical: https://answers.mindstick.com/qa/117158/how-to-upload-files-to-azure-blob-storage-using-azure-storage-blobs-in-asp-net-core  
category: "Azure Storage"  
tags: ["azure", "ASP-NET-Core", "Blob-Storage", "File-Upload", "dotnet"]  
reading_time: 1 minute  

---

# How to Upload Files to Azure Blob Storage using Azure.Storage.Blobs in ASP.NET Core?

Azure Blob Storage offers scalable object storage for unstructured data such as image files, documents, and media streams. In ASP.NET Core, managing uploads is made straightforward through the official SDK.

## Registering BlobServiceClient

In `Program.cs`, register the `BlobServiceClient` as a service using dependency injection:

```cs
using Azure.Storage.Blobs;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton(x =>
    new BlobServiceClient(builder.Configuration.GetConnectionString("AzureBlobStorage"))
);

var app = builder.Build();
```

## Implementing the File Upload Service

Inject `BlobServiceClient` into your service or API controller to upload files directly to a designated Blob container:

```cs
public class StorageService
{
    private readonly BlobServiceClient _blobServiceClient;

    public StorageService(BlobServiceClient blobServiceClient)
    {
        _blobServiceClient = blobServiceClient;
    }

    public async Task<string> UploadFileAsync(string containerName, IFormFile file)
    {
        var containerClient = _blobServiceClient.GetBlobContainerClient(containerName);
        await containerClient.CreateIfNotExistsAsync();

        var blobClient = containerClient.GetBlobClient(file.FileName);
        using var stream = file.OpenReadStream();
        await blobClient.UploadAsync(stream, overwrite: true);

        return blobClient.Uri.ToString();
    }
}
```


---

Original Source: https://answers.mindstick.com/qa/117158/how-to-upload-files-to-azure-blob-storage-using-azure-storage-blobs-in-asp-net-core

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
