Skip to content

Commit

Permalink
Limit storageaccount name length to 24 characters (#5396)
Browse files Browse the repository at this point in the history
* Limit storageaccount name length to 24 characters

* Check if the length of storageAccountName is more than 24
  • Loading branch information
Tapanila authored Apr 13, 2022
1 parent 4f62f8e commit 5da7f5b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion helpers/GenerateResourcesAndImage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ Function GenerateResourcesAndImage {
# Resource group names may contain special characters, that are not allowed in the storage account name
$storageAccountName = $storageAccountName.Replace("-", "").Replace("_", "").Replace("(", "").Replace(")", "").ToLower()
$storageAccountName += "001"


# Storage Account Name can only be 24 characters long
if ($storageAccountName.Length -gt 24){
$storageAccountName = $storageAccountName.Substring(0, 24)
}

New-AzStorageAccount -ResourceGroupName $ResourceGroupName -AccountName $storageAccountName -Location $AzureLocation -SkuName "Standard_LRS" -AllowBlobPublicAccess $AllowBlobPublicAccess -EnableHttpsTrafficOnly $EnableHttpsTrafficOnly

Expand Down Expand Up @@ -268,4 +274,4 @@ Function GenerateResourcesAndImage {
-var "install_password=$($InstallPassword)" `
-var "allowed_inbound_ip_addresses=$($AgentIp)" `
$builderScriptPath
}
}

0 comments on commit 5da7f5b

Please sign in to comment.