DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Josh Duffney
Josh Duffney

Posted on

Using Azure Storage with PowerShell

Create a Resource Group

New-AzResourceGroup -Name storagePractice -Location eastus
Enter fullscreen mode Exit fullscreen mode

Create a Storage Account

New-AzStorageAccount -Name storageaccountpractice -ResourceGroupName storagePractice -Location eastus -SkuName Standard_LRS
Enter fullscreen mode Exit fullscreen mode

Get Storage Account Key Value

$key = (Get-AzStorageAccountKey -ResourceGroupName storagepractice -Name storageaccountpractice)[0].value
Enter fullscreen mode Exit fullscreen mode

Create New Storage Content

$context = New-AzStorageContext -StorageAccountName storageaccountpractice -StorageAccountKey $key
Enter fullscreen mode Exit fullscreen mode

Create a Storage Blob Container

New-AzStorageContainer -Name images -Context $context -Permission Blob
Enter fullscreen mode Exit fullscreen mode

Upload Image to Azure Storage Blob Container

Set-AzStorageBlobContent -File ./books.png -Container images -Blob 'books.png' -Context $context
Enter fullscreen mode Exit fullscreen mode

List Contents of an Azure Blob Storage Container

Get-AzStorageBlob -Container images -Context $context
Enter fullscreen mode Exit fullscreen mode

Download Contents of Azure Blob Storage Container

Get-AzStorageBlobContent -Blob "books.png" `   
-Container images `        
-Destination "books2.png" `               
-Context $context
Enter fullscreen mode Exit fullscreen mode

Remove Azure Resource Group ( Cleanup )

Remove-AzResourceGroup -Name storagePractice -Force
Enter fullscreen mode Exit fullscreen mode

Sources

Quickstart: Upload, download, and list blobs by using Azure PowerShell

Top comments (0)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›