I’ve been learning Azure for a while and experimenting with various aspects of the Azure Cloud world. Storage Account is one of the potential areas which can be used to keep the information in form of the following.
- Azure Blob
- Azure File
- Azure Queues
- Azure Tables
An excerpt about Azure Storage - reference https://docs.microsoft.com/en-us/azure/storage/common/storage-introduction - "Azure Storage is Microsoft's cloud storage solution for modern data storage scenarios"
Azure Storage offers a massively scalable object store for data objects, a file system service for the cloud, a messaging store for reliable messaging, and a NoSQL store. Azure Storage is -
- Durable and highly available
Redundancy ensures that your data is safe in the event of transient hardware failures. You can also opt to replicate data across data centers or geographical regions for additional protection from local catastrophe or natural disaster. Data replicated in this way remains highly available in the event of an unexpected outage.
- Secure
All data written to Azure Storage is encrypted by the service. Azure Storage provides you with fine-grained control over who has access to your data.
- Scalable
Azure Storage is designed to be massively scalable to meet the data storage and performance needs of today's applications.
- Managed
Microsoft Azure handles maintenance and any critical problems for you.
- Accessible
Data in Azure Storage is accessible from anywhere in the world over HTTP or HTTPS. Microsoft provides SDKs for Azure Storage in a variety of languages -- .NET, Java, Node.js, Python, PHP, Ruby, Go, and others -- as well as a mature REST API. Azure Storage supports scripting in Azure PowerShell or Azure CLI. And the Azure portal and Azure Storage Explorer offer easy visual solutions for working with your data.
There are generally the following ways to create a Storage Account in Azure.
- Through Azure Resource Manager portal https://portal.azure.com
- Using PowerShell commands or cmdlet
In this article, I’ll be creating an Azure Storage account through Powershell commands, which is very easy to write. In a few minutes, you will get the complete storage account along with the Container and Resource group without jumping into Portal.
I believe this approach is useful especially in the professional world because you can create plenty of resources within the ARM portal through PowerShell in a very less time.
Prerequisites
- You should have Powershell ISE installed on your workstation.
- You should be an authenticated user on Azure Portal.
- You should possess a basic understanding of Azure.
Note
In Windows 10, PowerShell ISE comes by default, as shown below.
As soon as you open this, you will have the following window.
Now, it's time to execute the following command in the PowerShell Editor. You can execute all of them in a single go or can execute one by one.
Step 1
Execute the command - Add-AzureAccount
It will prompt the following window. Put your credentials like username and password as depicted in the below windows.
Step 2
Execute the following command in order to create a Storage Account using the Run Selection (F8). Kindly refer to the image below for the command line.
New-AzureStorageAccount -StorageAccountName "dotnetpiperstorage" -Description "dotnetpiperstorage" -Location "East US" -Type Standard_LRS
Step 3
Execute the following command.
Get-AzureStorageAccount
The above command confirms and returns the details of a recent storage account.
Step 4
Execute the following command-
Get-AzureStorageKey -StorageAccountName "dotnetpiperstorage"
Step 4
Execute the following commands -
- $storagekey = (Get-AzureStorageKey -StorageAccountName "dotnetpiperstorage").Primary
- $storagecontext = New-AzureStorageContext -StorageAccountName "dotnetpiperstorageContainer" -StorageAccountKey $storagekey
- $container = New-AzureStorageContainer -Name "dotnetpiperstorageContainer" -Permission Container -Context $storagecontext
Note
Any keyword created along with “$” sign is considered local variable and retains in the same session.
Step5
After creating the context and container sucessfuly, you can verify the follwoing cmdlet.
- Get - AzureStorageContainer - Context $storagecontext
- Add - AzureAccount
- New - AzureStorageAccount - StorageAccountName "dotnetpiperstorage" - Description "dotnetpiperstorage" - Location "East US" - Type Standard_LRS
- Get - AzureStorageAccount
- Get - AzureStorageKey - StorageAccountName "dotnetpiperstorage"
- New - AzureStorageKey - KeyType Primary - StorageAccountName "dotnetpiperstorage"#
- to create Storage Container
- $storagekey = (Get - AzureStorageKey - StorageAccountName "dotnetpiperstorage").Primary
- $storagecontext = New - AzureStorageContext - StorageAccountName "dotnetpiperstorage" - StorageAccountKey $storagekey
- $container = New - AzureStorageContainer - Name "dotnetpiperstoragecontainer" - Permission Container - Context $storagecontext
- Get - AzureStorageContainer - Context $storagecontext
Now, you can also jump into Azure Portal to see the stuff you have created in the last few steps.
Open - https://portal.azure.com -> All Services ->Storage Account
Click on Storage Account. It will take you on another screen, which has potential information about all the storage accounts available within subscription as depicted below.
Click on dotnetpiperstorage. It will take you the following screen which has detailed information about Storage Account.
Click on the blobs as shown on the above window to see the container which we’ve created recently using the above step.
That’s it.
Note
Azure Storage forces you to keep the name of the storage account in the lower font as well as for the container. Rather than jumping into ARM portal, you can easily create Azure Storage Account with these few commands.