Skip to content

Commit c29004a

Browse files
authored
Remove dots and dashes from the volume name to align with azd naming (#8631)
1 parent f9035bc commit c29004a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ public static IResourceBuilder<AzureContainerAppEnvironmentResource> AddAzureCon
223223
_ => throw new NotSupportedException()
224224
};
225225

226+
// Remove '.' and '-' characters from volumeName
227+
volumeName = volumeName.Replace(".", "").Replace("-", "");
228+
226229
share.Name = BicepFunction.Take(
227230
BicepFunction.Interpolate(
228231
$"{BicepFunction.ToLower(output.resource.Name)}-{BicepFunction.ToLower(volumeName)}"),
@@ -253,11 +256,10 @@ public static IResourceBuilder<AzureContainerAppEnvironmentResource> AddAzureCon
253256
identity.Name = BicepFunction.Interpolate($"mi-{resourceToken}");
254257
containerRegistry.Name = new FunctionCallExpression(
255258
new IdentifierExpression("replace"),
256-
new InterpolatedStringExpression(
257-
[
258-
new StringLiteralExpression("acr-"),
259+
new InterpolatedStringExpression([
260+
new StringLiteralExpression("acr-"),
259261
new IdentifierExpression(resourceToken.BicepIdentifier)
260-
]),
262+
]),
261263
new StringLiteralExpression("-"),
262264
new StringLiteralExpression(""));
263265
laWorkspace.Name = BicepFunction.Interpolate($"law-{resourceToken}");

tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ public async Task AddContainerAppEnvironmentAddsEnvironmentResource(bool useAzdN
32313231
.AddDatabase("db");
32323232

32333233
builder.AddContainer("cache", "redis")
3234-
.WithVolume("data", "/data")
3234+
.WithVolume("App.da-ta", "/data")
32353235
.WithReference(pg);
32363236

32373237
using var app = builder.Build();
@@ -3366,7 +3366,7 @@ param userPrincipalId string
33663366
}
33673367
33683368
resource shares_volumes_cache_0 'Microsoft.Storage/storageAccounts/fileServices/shares@2024-01-01' = {
3369-
name: take('${toLower('cache')}-${toLower('data')}', 60)
3369+
name: take('${toLower('cache')}-${toLower('Appdata')}', 60)
33703370
properties: {
33713371
enabledProtocols: 'SMB'
33723372
shareQuota: 1024
@@ -3375,7 +3375,7 @@ param userPrincipalId string
33753375
}
33763376
33773377
resource managedStorage_volumes_cache_0 'Microsoft.App/managedEnvironments/storages@2024-03-01' = {
3378-
name: take('${toLower('cache')}-${toLower('data')}', 32)
3378+
name: take('${toLower('cache')}-${toLower('Appdata')}', 32)
33793379
properties: {
33803380
azureFile: {
33813381
accountName: env_storageVolume.name

0 commit comments

Comments
 (0)