Creating a storage account with the portal, CLI and PowerShell

Article · 2 min read · Part 4 of 30

Naming rules, then the same storage account created three ways, with secure defaults.

Share on LinkedIn

Three ways to create the same account

Yesterday you chose a redundancy option. Today you create a storage account three ways: in the portal, with the Azure CLI and with Azure PowerShell. The settings are the same each time, so you can see how the portal choices map to command options.

Naming rules

A storage account name must be 3 to 24 characters long, use only lower-case letters and numbers, and be unique across all of Azure, because it becomes part of the endpoint address, for example https://stportfoliodemo01.blob.core.windows.net. A short prefix such as st, a workload name and a number works well.

In the portal

  1. Search for Storage accounts and select Create.
  2. On Basics, choose the subscription and resource group, enter the name, pick the region, choose Standard performance and the redundancy you chose yesterday.
  3. On Advanced, keep Require secure transfer on, set the Minimum TLS version to 1.2, and turn off Allow enabling anonymous access on individual containers unless you have a clear reason.
  4. Leave Networking on the defaults for now. Days 16 and 17 cover the firewall and private endpoints.
  5. Select Review + create, check the summary and select Create.

With the Azure CLI

az group create --name rg-storage-course --location uksouth

az storage account create \
  --name stportfoliodemo01 \
  --resource-group rg-storage-course \
  --location uksouth \
  --sku Standard_LRS \
  --kind StorageV2 \
  --min-tls-version TLS1_2 \
  --allow-blob-public-access false

The --sku value carries both the performance and the redundancy, for example Standard_LRS, Standard_ZRS or Standard_GRS.

With Azure PowerShell

New-AzResourceGroup -Name rg-storage-course -Location uksouth

New-AzStorageAccount -ResourceGroupName rg-storage-course `
  -Name stportfoliodemo01 `
  -Location uksouth `
  -SkuName Standard_LRS `
  -Kind StorageV2 `
  -MinimumTlsVersion TLS1_2 `
  -AllowBlobPublicAccess $false

Check what you built

Get-AzStorageAccount -ResourceGroupName rg-storage-course -Name stportfoliodemo01 |
  Select-Object StorageAccountName, Location, Kind, @{n='Sku';e={$_.Sku.Name}}, MinimumTlsVersion, AllowBlobPublicAccess

The output should show the region, StorageV2, your SKU, TLS1_2 and public access set to false.

Why scripts win

The portal is fine for learning. For real environments, a script or a template gives the same result every time, records exactly what was set, and can be reviewed before it runs. Day 29 builds the same account with Bicep and Terraform.

Today's task

Create one storage account with the CLI or PowerShell using the settings above, then open it in the portal and find each setting you chose. Delete the resource group when you finish if you do not want to keep it.