0

I am currently uploading files to an Azure blob via a scheduled Powershell script. Is there any way that I can do a check to make sure that the files have uploaded successfully? I am writing to a log file, but I want to delete the files that have uploaded from my on-prem storage after the upload.

The files have unique names. Is there any way I can do a compare > create file on-prem after successful compare? I'd then be able to create a script that would only delete the files if this file existed.

Thanks.

AngryDog
  • 11
  • 2
  • 1
    you can check the md5 hashes. https://stackoverflow.com/questions/63375981/azure-blob-md5-checksum-and-local-md5-checksum-not-matching/63376858#63376858 – silent Jan 18 '22 at 15:26
  • Thanks, I will have a look. I want this to be automated, so I need to trust it to run, create a file based on them matching and then delete the local copies. It'll only be uploading a few files a day. – AngryDog Jan 19 '22 at 13:01

1 Answers1

1

After upload of on-prem files with Azure Storage blob, you can list the blobs in the Azure Storage account and compare the file names with the On-prem files

If the file exists, you can delete the on-prem file

To list the blobs in an Azure Storage container, you can use the below command:

az storage blob list -c containerName --account-name storageAccountName
RamaraoAdapa
  • 2,837
  • 2
  • 5
  • 11
  • Thanks for your reply. I don't see the connection with how this would just look at the files just uploaded compared with what is on prem, and then delete them. I could run a separate task to delete the files from local storage, but I'm still just basically accepting that the file uploaded without proof. I'm not really sure what I want is possible without having a program do the upload, compare, delete. – AngryDog Feb 02 '22 at 11:41
  • If you want to compare the content inside the file, you can check the md5 hashes of the files – RamaraoAdapa Feb 02 '22 at 11:46
  • You might need to add the --access-key value ie. az storage blob list -c "" --account-key "" --account-name "" --query 'length(@")"' -o table – Fuzzy Analysis Jun 15 '22 at 01:21