| reviewed | 2023-12-01 |
|---|---|
| severity | Awareness |
| pillar | Operational Excellence |
| category | OE:04 Continuous integration |
| resource | Storage Account |
| resourceType | Microsoft.Storage/storageAccounts |
| online version | https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.Storage.Name/ |
Azure Resource Manager (ARM) has requirements for Storage Account names.
When naming Azure resources, resource names must meet service requirements. The requirements for Storage Account names are:
- Between 3 and 24 characters long.
- Lowercase letters or numbers.
- Storage Account names must be globally unique.
Consider using names that meet Storage Account naming requirements. Additionally consider naming resources with a standard naming convention.
To deploy Storage Accounts that pass this rule:
- Set the
nameproperty to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLengthandmaxLengthattributes.
For example:
@minLength(3)
@maxLength(24)
@description('The name of the resource.')
param name string
@description('The location resources will be deployed.')
param location string = resourceGroup().location
resource storageAccount 'Microsoft.Storage/storageAccounts@2024-01-01' = {
name: name
location: location
sku: {
name: 'Standard_GRS'
}
kind: 'StorageV2'
properties: {
allowBlobPublicAccess: false
supportsHttpsTrafficOnly: true
minimumTlsVersion: 'TLS1_2'
accessTier: 'Hot'
allowSharedKeyAccess: false
networkAcls: {
defaultAction: 'Deny'
}
}
}To deploy Storage Accounts that pass this rule:
- Set the
nameproperty to a string that matches the naming requirements. - Optionally, consider constraining name parameters with
minLengthandmaxLengthattributes.
For example:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "623188591179107280"
}
},
"parameters": {
"name": {
"type": "string",
"minLength": 3,
"maxLength": 24,
"metadata": {
"description": "The name of the resource."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location resources will be deployed."
}
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2024-01-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_GRS"
},
"kind": "StorageV2",
"properties": {
"allowBlobPublicAccess": false,
"supportsHttpsTrafficOnly": true,
"minimumTlsVersion": "TLS1_2",
"accessTier": "Hot",
"allowSharedKeyAccess": false,
"networkAcls": {
"defaultAction": "Deny"
}
}
}
]
}This rule does not check if Storage Account names are unique.