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.
Name | Supported Account Kinds | Description |
---|---|---|
Standard_LRS | Storage, BlobStorage, StorageV2 | Standard Locally Redundant Storage |
Standard_GRS | Storage, BlobStorage, StorageV2 | Standard Geo Replicated Storage |
Standard_RAGRS | Storage, BlobStorage, StorageV2 | Standard Read-Access Geo Replicated Storage |
Standard_ZRS | Storage, StorageV2 | Standard Zone Redundant Storage |
Premium_LRS | Storage, StorageV2, FileStorage, BlockBlobStorage | Provisioned IO Locally Redundant Storage |
Premium_ZRS | Storage, StorageV2 | Provisioned IO Locally Redundant Storage |
Standard_GZRS | Storage, StorageV2 | Provisioned IO Locally Redundant Storage |
Standard_RAGZRS | Storage, StorageV2 | Provisioned 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'
}
}