Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment pane shows unexpected error when substring contains bad param values #16454

Open
StephenWeatherford opened this issue Feb 20, 2025 · 1 comment

Comments

@StephenWeatherford
Copy link
Contributor

Bicep version
0.33.13 and .33.95 at least

Describe the bug

@description('The name of the Azure Storage account')
param storageAccountName string = toLower(substring('stg${uniqueString(resourceGroup().id, deployment().name)}', 0, 23))

@description('The name of the blob container')
param blobContainerName string = 'blobcontainer${uniqueString(resourceGroup().id, deployment().name)}'

@description('The name of the file share')
param fileShareName string = 'fileshare${uniqueString(resourceGroup().id, deployment().name)}'

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: storageAccountName
  location: resourceGroup().location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}

resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
  name: '${storageAccount.name}/default/${blobContainerName}'
  properties: {
    publicAccess: 'None'
  }
}

resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2022-09-01' = {
  name: '${storageAccount.name}/default/${fileShareName}'
  properties: {
    shareQuota: 100
  }
}

To Reproduce
Old-school deployment gives expected error:

 Deployment template validation failed: 'The template expression in parameter 'storageAccountName' at line '1' and column '302' is not valid: Unable to evaluate the template language function 'substring'. The index and length parameters must refer to a location within the string. The index parameter: '0', the length parameter: '23', the length of the string parameter: '16'. Please see https://aka.ms/arm-function-substring for usage details.'.
Status: 400 (Bad Request)
ErrorCode: InvalidTemplate

Deloyment pane gives this:

Image

@anthony-c-martin
Copy link
Member

@StephenWeatherford could you try this out with the latest from main? It looks like the same problem that #16257 intended to fix (which hasn't yet been released).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

2 participants