Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created November 13, 2025 12:41
Show Gist options
  • Select an option

  • Save AlexanderHolmeset/20de6f642e0368bbacd578a997294fd2 to your computer and use it in GitHub Desktop.

Select an option

Save AlexanderHolmeset/20de6f642e0368bbacd578a997294fd2 to your computer and use it in GitHub Desktop.
# This is how you can upload and download a file to/from Azure Blob Storage using PowerShell and a SAS URL.
# For download the SAS URL must have read permissions and for upload it must have write permissions.
# Specify the filename to upload
$Filename = "picture.png"
# Replace with your actual SAS URL
$SasUrl = "https://aiswedenholmes7080246781.blob.core.windows.net/files/$Filename?sp=rw&st=2025-11-13T12:03:14Z&se=2025-11-13T20:18:14Z&spr=https&sv=2024-11-04&sr=c&sig=Rb0Aqy5Hg6G0PZiJV1M8cYY5MvELK8TXN8gxCu4xqjU%3D"
# Read the file content as a byte array
$FileContent = [System.IO.File]::ReadAllBytes("./$Filename")
# Upload the file to Azure Blob Storage
Invoke-RestMethod -Uri $SasUrl `
-Method Put `
-Body $FileContent `
-Headers @{
"x-ms-blob-type" = "BlockBlob"
"Content-Type" = "application/octet-stream"
}
# Download the file back from Azure Blob Storage
Invoke-RestMethod -Uri $SasUrl `
-Method Get `
-OutFile "new_$Filename.png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment