Skip to content

Azure Functions Default Azure Storage name is too long #6257

@eerhardt

Description

@eerhardt

When deploying an Azure Functions app using the default/implicit Azure Storage account, the name used is too long and isn't getting a unique string in Azure. The storage account name needs to be unique across all of Azure.

https://learn.microsoft.com/en-us/azure/templates/microsoft.storage/storageaccounts?pivots=deployment-language-bicep#storageaccounts

var funcApp = builder.AddAzureFunctionsProject<Projects.AzureFunctionsEndToEnd_Functions>("funcapp")
    .WithExternalHttpEndpoints()
    .WithReference(eventHubs)
    .WithReference(blob)
    .WithReference(queue);

Produces the following bicep:

resource defaultazfuncstorage2380b 'Microsoft.Storage/storageAccounts@2024-01-01' = {
  name: take('defaultazfuncstorage2380b${uniqueString(resourceGroup().id)}', 24)
  kind: 'StorageV2'
  location: location
  sku: {
    name: 'Standard_GRS'
  }
  properties: {
    accessTier: 'Hot'
    allowSharedKeyAccess: false
    minimumTlsVersion: 'TLS1_2'
    networkAcls: {
      defaultAction: 'Allow'
    }
  }
  tags: {
    'aspire-resource-name': 'defaultazfuncstorage2380b'
  }
}

Note this line: name: take('defaultazfuncstorage2380b${uniqueString(resourceGroup().id)}', 24)

We are already over the 24 char limit with our default name + 5 SHA chars from the AppHost path.

If 2 developers are working on the same app in the same file location (ex. C:\git), when they deploy to separate resource groups, the Storage account is going to conflict because they both will try to use defaultazfuncstorage2380 as the name. This is the same if you are deploying the same app twice from a GitHub Action or Azure Devops pipeline.

We should make the prefix shorter to allow for more unique characters to come from the uniqueString portion.

cc @captainsafia

Metadata

Metadata

Assignees

Labels

area-integrationsIssues pertaining to Aspire Integrations packagesazureIssues associated specifically with scenarios tied to using Azureazure-functionsIssues related to the Azure Functions integration

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions