From 9bf7ee2cc7baf8e51ea7ab61d5c333f7f7e27cca Mon Sep 17 00:00:00 2001 From: david Date: Tue, 9 Oct 2018 19:30:34 +0000 Subject: [PATCH] =?UTF-8?q?Create=20Post=20=E2=80=9Cpowershell-get-filehas?= =?UTF-8?q?h-and-azure-storage=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...powershell-get-filehash-and-azure-storage.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 source/_posts/powershell-get-filehash-and-azure-storage.md diff --git a/source/_posts/powershell-get-filehash-and-azure-storage.md b/source/_posts/powershell-get-filehash-and-azure-storage.md new file mode 100644 index 0000000..d57f575 --- /dev/null +++ b/source/_posts/powershell-get-filehash-and-azure-storage.md @@ -0,0 +1,17 @@ +--- +title: PowerShell Get-FileHash and Azure Storage +date: '2018-10-09T13:22:32-05:00' +tags: + - powershell azure storage hash +--- +TL;DR + +When uploading files to Azure Storage and setting the Content-MD5 property use `[System.Convert]::ToBase64String`. Using `Get-FileHash` or `[System.BitConverter]::ToString` will cause problems; the Azure Storage SDK uses the Base64 format but the BitConverter produces a hex value format. Both methods produce the same hash, but using different formats. + +### +I was messing with a [custom script extension (CSE)](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows) for a VM; everything was fine until I started automating the uploading of the powershell script for the CSE into Azure blob storage. I decided to set the `Content-MD5` for the blobs so I could keep from uploading same exact files repeatedly (then only upload when it's changed). + +I kept getting: +``` +Failed to download all specified files. Exiting. Error Message: One or more errors occured. +```