[Issue] Anonymous volume mounts in Aspire cause deployment breaks
- Dominant language
- Go
- Stars
- 569
- Forks
- 364
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 136
Description
- [x] Make sure you've installed the latest version using [instructions in the wiki](../wiki/install)
**Output from `azd version`**
Run `azd version` and copy and paste the output here:
azd version 1.13.2 (commit 451ec3fc430f551be5657e34df3cd2de6256e42b)
**Describe the bug**
In Aspire, when using an anonymous volume mount, the deployment will fail with
```
Deployment Error Details:
InvalidResourceName: The specifed resource name contains invalid characters.
```
**To Reproduce**
`azd up` an Aspire app with the following code:
```C#
var redis = builder.AddRedis("cache")
.WithLifetime(ContainerLifetime.Persistent)
.WithVolume("/data");
```
This produces manifest:
```json
"cache": {
"type": "container.v0",
"connectionString": "{cache.bindings.tcp.host}:{cache.bindings.tcp.port},password={cache-password.value}",
"image": "docker.io/library/redis:7.4",
"entrypoint": "/bin/sh",
"args": [
"-c",
"redis-server --requirepass $REDIS_PASSWORD"
],
"volumes": [
{
"target": "/data",
"readOnly": false
}
],
"env": {
"REDIS_PASSWORD": "{cache-password.value}"
},
"bindings": {
"tcp": {
"scheme": "tcp",
"protocol": "tcp",
"transport": "tcp",
"targetPort": 6379
}
}
},
```
**Expected behavior**
The deploy should succeed.
**Actual behavior**
The deploy fails because the bicep generated for the file share is not valid:
```bicep
resource cacheFileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2022-05-01' = {
parent: storageVolumeFileService
name: take('${toLower('cache')}-${toLower('')}', 60)
properties: {
shareQuota: 1024
enabledProtocols: 'SMB'
}
}
```
I don't think the file share can end in a `-`.
**Environment**
Information on your environment:
* Language name and version
* IDE and version : [e.g. Visual Studio 16.3]
**Additional context**
Add any other context about the problem here.
Contributor guide
Assessment
This issue has not been assessed yet.