Set-AzStorageBlobContent takes a file location to be uploaded to cloud. is there way I can pass a System.IO.Stream to a Block Blob in PowerShell?
I figured out how to. it is kind of simple and thanks to, https://microsoft.github.io/AzureTipsAndTricks/blog/tip76.html.
In was able to extract the content of a zip file into Azure Storage block blob directly without having to extract the files locally. This below example can be enhanced to recursively upload all entries within a zip file.
Import-Module -Name Az
$ZipArchive = [System.IO.Compression.ZipFile]::OpenRead("C:\...\temp.zip");
$ZipEntry = $ZipArchive.Entries[0]
$DeflateStream = $ZipEntry.Open();
$storageAccountName= 'storageAccountName'
$containerName= 'containerName'
Get-AzSubscription | Select-Object -First 1 | Set-AzContext
$StorageAccount = Get-AzStorageAccount -ResourceGroupName ResourceGroupName | Where-Object{$_.StorageAccountName -match $storageAccountName}
$StorageContext = New-AzStorageContext -StorageAccountName $StorageAccount.StorageAccountName -StorageAccountKey (Get-AzStorageAccountKey -ResourceGroupName $StorageAccount.ResourceGroupName -Name $StorageAccount.StorageAccountName | select -First 1 ).Value
$Container = Get-AzStorageContainer -Name $containerName -Context $StorageContext
$BlockBlob = $Container.CloudBlobContainer.GetBlockBlobReference("Temp/temp.pdf")
$BlockBlob.UploadFromStream($DeflateStream);