In one of my previous blogs, I've explained how to download file from Azure Blob storage…
In this example shows you how to upload a file to Azure Blob Storage by just using the native REST API and a Shared Access Signature (SAS) ...
The following PowerShell example does upload a single log file:
#Our source File:
$file = "C:\ConfigMgrSetup.log"
#Get the File-Name without path
$name = (Get-Item $file).Name
#The target URL wit SAS Token
$uri = "https://test.blob.core.windows.net/logs/$($name)?st=2019-04-03T07%3A28%3A36Z&se=2019-04-03T07%3A28%3A36Z&sp=rwdl&sv=2018-03-28&sr=c&sig=Y3%2BBRkH5ivySba7qAFQ%2BnjF2HoVg0Lr4bjVPrKZh6mU%3D"
#Define required Headers
$headers = @{
'x-ms-blob-type' = 'BlockBlob'
}
#Upload File...
Invoke-RestMethod -Uri $uri -Method Put -Headers $headers -InFile $file
The URI is using the following format:
{URL}/{Container}/[Folder Structure/]{FileName}?{SAS Token}
The SAS Token is very handy as it allows to limit the time where the token can be used.
That's it...