Azure provisioning can fail when Aspire invokes az bicep build --stdout
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 201
Description
## Summary
Azure provisioning for Foundry resources can fail while Aspire is compiling generated Bicep with Azure CLI. The failure occurs inside `az bicep build --stdout`, where Azure CLI/Python crashes while initializing stdio.
## Scenario
A TypeScript AppHost models a Microsoft Foundry project, model deployment, prompt agent, and an executable/Node resource configured with `asHostedAgent(project, ...)`.
During `aspire start`, the Foundry resources enter provisioning, but fail before the hosted-agent compute resource can start.
## Actual behavior
Foundry resources fail to provision/deploy, and the hosted-agent resource remains waiting on the Foundry resource and project.
Representative log:
```text
[foundry] Provisioning foundry...
[foundry] Error provisioning foundry.
System.InvalidOperationException: Command /opt/homebrew/bin/az bicep build --file "/var/folders/.../foundry.module.bicep" --stdout returned non-zero exit code 1
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
OSError: [Errno 9] Bad file descriptor
Current thread 0x00000001ed121e80 (most recent call first):
at Aspire.Hosting.Azure.Provisioning.Internal.BicepCliCompiler.ExecuteCommand(ProcessSpec processSpec)
at Aspire.Hosting.Azure.Provisioning.Internal.BicepCliCompiler.CompileBicepToArmAsync(String bicepFilePath, CancellationToken cancellationToken)
at Aspire.Hosting.Azure.Provisioning.BicepProvisioner.GetOrCreateResourceAsync(...)
```
A Foundry project resource shows the same shape of failure for its generated project Bicep module.
## Expected behavior
Aspire should successfully compile the generated Bicep and continue provisioning, or surface a stable Azure CLI/Bicep failure without the Python stdio crash.
## Environment
- OS: macOS / Darwin
- Aspire CLI: 13.4.2
- AppHost SDK: 13.4.0
- Azure CLI: 2.78.0
- Bicep CLI: 0.38.33
## Notes
Running `az bicep build --file --stdout` directly in the same shell succeeds. The failure was observed when Aspire invoked `az bicep build --stdout` as part of Azure provisioning for generated Foundry Bicep resources.
Contributor guide
Research direction
Start with Aspire.Hosting.Azure.Provisioning.Internal.BicepCliCompiler, especially ExecuteCommand and CompileBicepToArmAsync, then follow BicepProvisioner.GetOrCreateResourceAsync. Compare Aspire's invocation of `az bicep build --file ... --stdout` with the direct command that succeeds on macOS. Done means generated Foundry Bicep compiles during provisioning without the Python stdio crash, or the Azure CLI failure is surfaced stably.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100