Bicep codegen: duplicate identifier when blob container resource is named 'blobs'; CLI swallows bicep errors
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
When using `addBlobContainer('blobs', { blobContainerName: 'plantdata' })` on an Azure Storage resource, the generated Bicep produces two resources both named `blobs`:
```bicep
resource blobs 'Microsoft.Storage/storageAccounts/blobServices@2024-01-01' = {
name: 'default'
parent: storage
}
resource blobs 'Microsoft.Storage/storageAccounts/blobServices/containers@2024-01-01' = {
name: 'plantdata'
parent: blobs
}
```
This causes a Bicep compilation error:
```
Error BCP028: Identifier "blobs" is declared multiple times. Remove or rename the duplicates.
```
The blob **service** resource automatically takes the name from the container resource name passed to `addBlobContainer()`, which collides when the user chooses `'blobs'` as the Aspire resource name.
**Additionally, the Aspire CLI does not surface the actual Bicep compilation errors.** Even with `--debug`, the only output is:
> `Deployment failed: Command /opt/homebrew/bin/az bicep build --file "...storage.module.bicep" --stdout returned non-zero exit code 1`
The underlying Bicep error (BCP028 duplicate identifier) is swallowed, making this very difficult to diagnose. The CLI should propagate stderr/stdout from the `az bicep build` command so users can see what actually went wrong.
### Expected Behavior
1. The generated Bicep should use distinct identifiers for the blob service and blob container resources (e.g., `blobs_service` and `blobs` or similar), regardless of the Aspire resource name chosen.
2. The Aspire CLI should output the full Bicep compilation error messages when `az bicep build` fails, not just the exit code.
### Steps To Reproduce
AppHost (TypeScript):
```typescript
const blobs = builder.addAzureStorage('storage')
.runAsEmulator()
.addBlobContainer('blobs', { blobContainerName: 'plantdata' });
await builder.addNextJsApp('web', '.')
.withReference(blobs);
```
Then deploy with `aspire publish`.
### Exceptions (if any)
```
Deployment failed: Command /opt/homebrew/bin/az bicep build --file "/var/folders/.../aspire-bicep.../storage.module.bicep" --stdout returned non-zero exit code 1
Step 'build-web' failed: A task was canceled.
```
Actual Bicep error (only visible when manually running `az bicep build`):
```
storage.module.bicep(25,10) : Error BCP028: Identifier "blobs" is declared multiple times.
storage.module.bicep(30,10) : Error BCP028: Identifier "blobs" is declared multiple times.
```
### .NET Version info
```
.NET SDK 10.0.201
Runtime: 10.0.5
OS: macOS 26.4 (arm64)
```
### Anything else?
**Aspire CLI version:** 13.3.0-preview.1
**Workaround:** Rename the blob container resource to something other than `'blobs'` (e.g., `addBlobContainer('plantdata', ...)`).
Related closed issues: #11106, #6074
Contributor guide
Assessment
This issue has not been assessed yet.