From 39d56cee0b56beecd8e668464d66324b68ca523c Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Tue, 8 Apr 2025 09:11:41 -0500 Subject: [PATCH] Remove dots and dashes from the volume name to align with azd naming --- .../AzureContainerAppExtensions.cs | 10 ++++++---- .../AzureContainerAppsTests.cs | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs index 3c942f9aad1..0d819811e5f 100644 --- a/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs +++ b/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs @@ -223,6 +223,9 @@ public static IResourceBuilder AddAzureCon _ => throw new NotSupportedException() }; + // Remove '.' and '-' characters from volumeName + volumeName = volumeName.Replace(".", "").Replace("-", ""); + share.Name = BicepFunction.Take( BicepFunction.Interpolate( $"{BicepFunction.ToLower(output.resource.Name)}-{BicepFunction.ToLower(volumeName)}"), @@ -253,11 +256,10 @@ public static IResourceBuilder AddAzureCon identity.Name = BicepFunction.Interpolate($"mi-{resourceToken}"); containerRegistry.Name = new FunctionCallExpression( new IdentifierExpression("replace"), - new InterpolatedStringExpression( - [ - new StringLiteralExpression("acr-"), + new InterpolatedStringExpression([ + new StringLiteralExpression("acr-"), new IdentifierExpression(resourceToken.BicepIdentifier) - ]), + ]), new StringLiteralExpression("-"), new StringLiteralExpression("")); laWorkspace.Name = BicepFunction.Interpolate($"law-{resourceToken}"); diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs index 4fb643c8fd1..d2c7508070a 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs @@ -3231,7 +3231,7 @@ public async Task AddContainerAppEnvironmentAddsEnvironmentResource(bool useAzdN .AddDatabase("db"); builder.AddContainer("cache", "redis") - .WithVolume("data", "/data") + .WithVolume("App.da-ta", "/data") .WithReference(pg); using var app = builder.Build(); @@ -3366,7 +3366,7 @@ param userPrincipalId string } resource shares_volumes_cache_0 'Microsoft.Storage/storageAccounts/fileServices/shares@2024-01-01' = { - name: take('${toLower('cache')}-${toLower('data')}', 60) + name: take('${toLower('cache')}-${toLower('Appdata')}', 60) properties: { enabledProtocols: 'SMB' shareQuota: 1024 @@ -3375,7 +3375,7 @@ param userPrincipalId string } resource managedStorage_volumes_cache_0 'Microsoft.App/managedEnvironments/storages@2024-03-01' = { - name: take('${toLower('cache')}-${toLower('data')}', 32) + name: take('${toLower('cache')}-${toLower('Appdata')}', 32) properties: { azureFile: { accountName: env_storageVolume.name