'MD5 is not a known hash algorithm' exception while trying to upload a blob to Azure Cloud?

Daniel Avadanei 41 Reputation points
2021-12-23T11:21:32.467+00:00

I'm trying to upload a file in Azure by using a SAS token but I receive this error while I try to upload the file :

MD5 is not a known hash algorithm

I have these 2 methods that I use, one to generate the file link which will be used to upload the file:

 public string GetBlobSASUploadFileLink(string fileName)
   {
            var connectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", StorageAccountName, AccessKey);
            var storageAccount = CloudStorageAccount.Parse(connectionString);
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer container = blobClient.GetContainerReference(FilesContainer);

            SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();
            sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(5);
            sasConstraints.Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create;

            var blob = container.GetBlockBlobReference(fileName);
            return string.Format("{0}{1}", blob.Uri, blob.GetSharedAccessSignature(sasConstraints));
   }

And this method where also the exception is thrown, which should upload the file in Azure:

public async Task UploadFilesToBlob(string fileLink, IBrowserFile file)
 {
        try
        {
            var cloudBlockBlob = new CloudBlockBlob(new Uri(fileLink));
            await cloudBlockBlob.UploadFromStreamAsync(file.OpenReadStream(912000000));
        }
        catch (Exception ex)
        {

        }
  }

In this second method in the UploadFromStreamAsync method the exception is thrown. I'm guessing the framework uses the MD5 algorithm but the Azure uses another cryptographic hashing algorithm but I don't know what should be done.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sumarigo-MSFT 47,466 Reputation points Microsoft Employee Moderator
    2021-12-24T12:26:42.123+00:00

    @Daniel Avadanei Thanks for raising this question! Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused

    Can you try to regenerate the SAS token and try again! If the issue still persist can you please share the screenshot of the issue!

    Based on the error message : There is a similar thread discussion in the SO forum, please refer to the suggestion

    Please let us know if you have any further queries. I’m happy to assist you further.

    ----------

    Please do not forget to160401-screenshot-2021-12-10-121802.png and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.