I've tried lots of different approaches & read lots of answers on SO but reaching out for help with this as I've hit a wall.

I have a storage account & container on azure, I'm successfully uploading images there but for some reason they seem to be corrupting.

I cannot access any image via an img tag nor can I view them (in windows photos) if I download them directly from the container.

I believe I have the correct configuration, public access level **blob** (I've also tried public access level **container**).

*container access level*
[![access level img](https://i.stack.imgur.com/RHgeu.png)](https://i.stack.imgur.com/RHgeu.png)

*view of the uploaded blob*
[![azure blob img](https://i.stack.imgur.com/pYd62.png)](https://i.stack.imgur.com/pYd62.png)

The image doesn't display via the url on my razor page

*html img tag*
[![missing img razor page](https://i.stack.imgur.com/lp8lk.png)](https://i.stack.imgur.com/lp8lk.png)

Nor am I able to view it if I download & open in windows

*downloaded img from container*
[![corrupt image](https://i.stack.imgur.com/KpK1W.png)](https://i.stack.imgur.com/KpK1W.png)

*2 examples of filestream approaches I've tried below*

```
    //approach 1   

        using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
                    {
                        BlobClient blobClient = container.GetBlobClient(fileName);
                        await blobClient.UploadAsync(fileStream, new BlobHttpHeaders { ContentType = "image/jpg" });
                    }

    //approach 2

            using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
            {
                container.UploadBlob(attachment.FileName, fileStream);
            }

//service
    public async Task<bool> UploadSample(IFormFile attachment)
            {
                var configSection = Configuration.GetSection("AzureBlobStorge");
                var connectionString = configSection.GetSection("ConnectionString").Value;
                var containerName = configSection.GetSection("ContainerName").Value;

                string fileName = Path.GetFileName(attachment.FileName);
                string filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\profiles", fileName);

                BlobContainerClient container = new BlobContainerClient(connectionString, containerName);

                container.SetAccessPolicy(PublicAccessType.BlobContainer);

                using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
                {
                    container.UploadBlob(attachment.FileName, fileStream);

                    //BlobClient blobClient = container.GetBlobClient(fileName);
                    //await blobClient.UploadAsync(fileStream, new BlobHttpHeaders { ContentType = "image/jpg" });
                }
                return true;
            }

//controller
        [HttpPost]
        [ActionName("ProfilePicsAsync")]
        [ValidateAntiForgeryToken]
        public async Task<ActionResult> ProfilePicsAsync(Members item)
        {
            try
            {
                IFormFile formFile = HttpContext.Request.Form.Files[0];
                var member = await _cosmosDbService.GetItemAsync(formFile.Name); //Id passed in the formfile object under name
                if (ModelState.IsValid)
                {
                    if (IsAdminUser())
                    {
                        if (formFile != null)
                        {
                            await _blobStorageService.UploadSample(formFile);
                        }
                        return RedirectToAction("Index");
                    }
                    return BadRequest("Not Authorised");
                }
            }
            catch (Exception ex)
            {
                if(ex is BusinessRuleException)
                {
                    return BadRequest(new BusinessRuleException(ex.Message));
                }
            }

//view
<form asp-action="ProfilePicsAsync" asp-controller="Home" method="post" enctype="multipart/form-data">
    @Html.HiddenFor(m => m.Id)
    <p>INPUT</p>
    <input asp-for="Attachment" Name="@Model.Id" />
    <button type="submit" id="btnUpload" class="btn btn-primary">Upload</button>
</form>

```