DEV Community 👩‍💻👨‍💻

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)

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.