Posts

Showing posts with the label PowerShell

Copying Azure Blob Storage Containers Between Accounts With PowerShell and AzCopy

A few months ago I wrote about backing up and restoring Azure blobs from a local environment. You can read that post  here . This is not an efficient approach for moving blobs from one Azure storage account to another. In this post I will show you how to copy all containers from one account to another using PowerShell and how to copy individual Azure storage containers using AzCopy. Copying All Containers with PowerShell This script will copy all containers from one Azure storage account to another. This can be useful for populating Azure development accounts. First we will set up our Azure storage accounts and create a storage context for each: $SourceAzureAccountName = "SourceAzureAccount" $SourceAzureKey = "SourceAzureKey" $DestAzureAccountName = "DestAzureAccount" $DestAzureKey = "DestAzureKey" $SourceCtx = New-AzureStorageContext $SourceAzureAccountName -StorageAccountKey $SourceAzureKey $DestCtx = New-AzureStorageContext $DestAzur...

Azure Blob Removal and Backup/Restore with PowerShell

Azure Blob Storage is a great service for storing unstructured object data in the cloud. In the development phase of  an application utilizing Azure Blob Storage, it can be necessary to wipe out an Azure test account as they get cluttered with test data. In a production application we need a way to backup valuable blob data and restore as needed. In this blog post, I will show you how to do each of these actions using Azure PowerShell. Removal This script will remove all containers from an Azure instance. This is useful for clearing out Azure development accounts. First we need to connect to our Azure storage account and create a storage context: $AzureAccountName = "TestAzureAccount" $AzureKey = "azurekey" $Ctx = New-AzureStorageContext $AzureAccountName -StorageAccountKey $AzureKey Next we loop through all Azure containers in the account and delete them along with their contents. The -Force parameter is added so we are not prompted when deleting containe...