In recent days there has been a push to move our team's in-person presentations online. In some cases we've been asked to record our presentations. Storage has quickly become an issue and so I have been investigating ways to transfer the recorded presentations to the cloud. Now the transfer can take place via GUI however automating the transfer might be needed in future. Luckily uploading files to Azure Storage via PowerShell is an option.
Lets get started:
Install-Module -Name Az -AllowClobber
$StorageURL = "https://<storagename>.blob.core.windows.net/STORAGE_CONTINER/" $FileName = "<filename>" $SASToken = "st=2020-03-10T23%3A19%3A17Z&se=2020-03-11T23%3A19%3A17Z&sp=rl&sv=2018-03-28&sr=b&sig=RANDOMCHARS" $blobUploadParams = @{ URI = "{0}/{1}?{2}" -f $StorageURL, $FileName, $SASToken Method = "PUT" Headers = @{ 'x-ms-blob-type' = "BlockBlob" 'x-ms-blob-content-disposition' = "attachment; filename=`"{0}`"" -f $FileName 'x-ms-meta-m1' = 'v1' 'x-ms-meta-m2' = 'v2' } Body = $Content Infile = $FileToUpload }NOTE: Be sure to replace <storagename> found in line 1 and <filename> found in line 2.
As always, please share your comments below on bettering the above script or any questions you may have.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.