Azure – Storage account – Bicep – An easy win for your environment

A Storage account is one of the easiest things about azure bicep to deploy into an azure environment. First we’ll need to declare a resource and give it a name. You can call the resource name whatever you like, for this example I’ll use ‘toyfactory’

In the first line of a resource you will see the resource and it’s api call used to create the resource

Next, the actual name of the resource to be provisioned in the environment. A resource name can be stored as a static name i.e. name: ‘mystorageaccountname’ or it can be stored as a parameter. name: storageAccountName param storageAccountName string = ‘mystorageaccountname’

You can specify the location in the same manner as the name by storing it as a static parameter or a parameter.

If you are provisioning a single template resource, It is good practice to store the static parameters in the declared resource and not wrap them as variables. If you will be working with many templates, consider wrapping your static values in a parameter and storing the parameters in a ‘main’ file. A main file will be covered in later articles.

All possible sku types can be found in the table below. Determine the most appropriate type to fit your needs.

NameSupported Account KindsDescription
Standard_LRSStorage, BlobStorage, StorageV2Standard Locally Redundant Storage
Standard_GRSStorage, BlobStorage, StorageV2Standard Geo Replicated Storage
Standard_RAGRSStorage, BlobStorage, StorageV2Standard Read-Access Geo Replicated Storage
Standard_ZRSStorage, StorageV2Standard Zone Redundant Storage
Premium_LRSStorage, StorageV2, FileStorage, BlockBlobStorageProvisioned IO Locally Redundant Storage
Premium_ZRSStorage, StorageV2Provisioned IO Locally Redundant Storage
Standard_GZRSStorage, StorageV2Provisioned IO Locally Redundant Storage
Standard_RAGZRSStorage, StorageV2Provisioned IO Locally Redundant Storage

Storage account ‘kind’ possible values are as follows…
Storage
StorageV2
BlobStorage
FileStorage
BlockBlobStorage

The accessTier will determine the cost of your storage account. the ‘Hot’ access tier is the most expensive and is used for data that will be accessed frequently. The ‘Cool’ access tier is used for data that will be accessed infrequently. Lastly, the ‘Archive’ Tier is used for data that is is rarely ever accessed and also has the lowest cost as putting data in this type of accessTier data in the archive tier can take up to 15 hours to become available.

Here is what a full example looks like of a working resource in azure bicep.

param location string = resourceGroup().location
param storageAccountName string = 'prefix${uniqueString(resourceGroup().id)}'

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
  name: storageAccountName
  location: location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}

Leave a Comment

Your email address will not be published. Required fields are marked *