Interact with Azure blob storage using PowerShell

Interact with Azure blob storage using PowerShell

Q. How can I interact with Azure blob storage using PowerShell?

A. Azure block blobs enable pretty much anything to be stored, for example a media file, document. You can upload and download data using REST APIs, CLI, graphical tools like Azure Storage Explorer and PowerShell.

The PowerShell below is a simple demo that creates a new container and then uploads an image.

$StrContext = New-AzureStorageContext -ConnectionString "<connection string>"

#Blobs
$StrContainer = 'images'
#Create a new continaer
New-AzureStorageContainer -Context $StrContext -Name $StrContainer 
#Upload all items from a path to the container
Get-ChildItem –Path C:\Users\josavi\OneDrive\Documents\TestPictures\* | Set-AzureStorageBlobContent -Context $StrContext -Container $StrContainer
#Browse
Get-AzureStorageBlob -Context $StrContext -Container $StrContainer
#Download with Get-AzureStorageBlob ... | Get-AzureStorageBlobContent -Destination <local> -Context $StrContext
#Remove the content
Get-AzureStorageBlob -Context $StrContext -Container $StrContainer | Remove-AzureStorageBlob -Context $StrContext
#Remove the container
Remove-AzureStorageContainer -Context $StrContext -Name $StrContainer

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish