I'm new to Azure Blob Storage and I've written a PowerShell script for uploading SQL Server backup files from a given folder to my Azure Container. When I execute it a file is appearing in Azure but it's 0 Bytes in size. Here's my code:
#Finds newest .bak file in folder
$dir = "I:\Backup\*.bak"
$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
#Get the File-Name without path
$name = (Get-Item $latest).Name
#The target URL wit SAS Token
$uri = "https://*****.blob.core.windows.net/sapprodback/$($name)?***My SAS Token is here***"
#Define required Headers
$headers = @{
'x-ms-blob-type' = 'BlockBlob'
}
#Upload File...
Invoke-RestMethod -Uri $uri -Method Put -Headers $headers -InFile $latest
What am I missing?