5 Ways to Manage Your Storage Account on Microsoft Azure Cloud

This post was first published at Medium

Microsoft Azure Cloud platform provides multiple ways to the developers to manage the storage account on Azure. You can use a user-friendly GUI tool called Storage Explorer to manage your storage account, you can write a script via Azure CLI or PowerShell to manage it, you can write code to operate it, and you can use a command-line utility called AzCopy to copy blobs or files to or from a storage account. I will show these different approaches to manage your Azure storage account.

#1 Using The Azure Storage Explorer Tool

The first and I think the easiest and most intuitive way is to use the Azure Storage Explorer tool. You can access this tool directly on your storage account panel.

Then you can create a new container easily.
And upload a file to the container easily.
In addition to the tool integrated with the Azure portal, you can also download a standalone Azure Storage Explorer application from the Azure website.

https://azure.microsoft.com/en-us/features/storage-explorer/

As you can see in the following screenshot, the standalone Azure Storage Explorer application supports different operation systems, such as Windows, macOS, and Linux.

I’m using macOS, so I downloaded the macOS version and opened the tool to operate my storage account on Azure cloud.

# 2 Using Azure CLI

The second way is using the Azure CLI tool. The Azure CLI tool is available to install in Windows, macOS, and Linux environments. Cos I’m using macOS, so I installed this tool via Homebrew.

brew update && brew install azure-cli

If you want to know more about how to install this tool, you can check this out.

https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?WT.mc_id=DT-MVP-5001664

After installing the Azure CIL tool, you can run the az storage command in your terminal, and you can get more details of this command.

you can manage storage accounts, containers within a storage account, etc. For example, we can use the following command to create another container named fromazcli in our azuretipsstorage storage account.

az storage container create --account-name azuretipsstorage --name fromazcli

If you want to know more about the commands used to manage the storage account, you can check it out.

https://docs.microsoft.com/en-us/cli/azure/storage/account?WT.mc_id=DT-MVP-5001664&view=azure-cli-latest

And of course, if you prefer to run those commands on the Azure portal, you can open the cloud shell and run those Azure CLI commands directly on the Azure cloud.

# 3 Using PowerShell

PowerShell is another tool you can use to manage your storage account on Azure. Initially, Windows PowerShell was built on the .NET Framework and only worked on Windows systems. With the current release, PowerShell uses .NET Core 5.0 as its runtime and runs on Windows, macOS, and Linux platforms. Because the same reason, so I installed PowerShell via Homebrew on macOS.

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?WT.mc_id=DT-MVP-5001664&view=powershell-7.1

And before you can access your storage account resources on Azure from PowerShell, you need to install the Az.Storage module.

Install-Module Az.Storage

By default, the PowerShell gallery isn’t configured as a trusted repository for PowerShellGet, so the first time you use the PSGallery you will see the above prompt. Answer Yes or Yes to All to continue with the installation. After the installation, you can run Get-Module to list the modules installed.

Then you can use the Get-AzRmStorageContainer to list containers within a storage account. And of course, you still can access the could shell tool on the Azure portal to run those PowerShell commands. And you will find the following link is helpful if you are interesting in these PowerShell commands.

https://docs.microsoft.com/en-us/powershell/module/az.storage/?WT.mc_id=DT-MVP-5001664&view=azps-5.5.0

# 4 Using Azure Storage Client Library

If you prefer to write code to manage your Azure Storage Account, the Azure storage client library is your option. Currently, there are two versions of the SDK available, the Azure storage client library v11 is a legacy version and the latest version is v12.

To install the SDK is relatively easy, you can use NuGet in your IDE to install it or you can use the dotnet add package command.

dotnet add package Azure.Storage.Blobs

After installing the sdk, you can create container and upload files to the container. As you can see in the following code snippet.

// Create a container.
var blobServiceClient = new BlobServiceClient(storageconnstring);

var containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);
// Create a blob.
var blobClient = containerClient.GetBlobClient(filename);

using FileStream uploadFileStream = File.OpenRead(filepath);
await blobClient.UploadAsync(uploadFileStream, true);
uploadFileStream.Close();

# 5 Using AzCopy Tool

AzCopy is a command-line utility that you can use to copy blobs or files to or from a storage account. And this tool supports Windows, macOS and Linux. You can download it from the following link.

https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10?WT.mc_id=DT-MVP-5001664

And the following link shows how to use AzCopy to upload files to Azure Blob storage.

https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-blobs-upload?WT.mc_id=DT-MVP-5001664

As mentioned above, Microsoft Azure provides a variety of ways to manage storage accounts. Now it’s your turn to try these ways yourself!


Thanks for reading and hope it’s helpful.

Have a chat at https://www.linkedin.com/in/chenjd/


Subscribe To Jiadong Chen's Blog

Avatar
Jiadong Chen
Cloud Architect/Senior Developer

Cloud Architect at Company-X | Microsoft MVP, MCT | Azure Certified Solutions Architect & Cybersecurity Architect Expert | Member of .NET Foundation | Packt Author ㅣ Opinions = my own.

comments powered by Disqus

Related