Simple local provisioning fails in devcontainer on first launch
- 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
Aspire 9.5.1, devcontainer running mcr.microsoft.com/devcontainers/dotnet:9.0
The (simple) code in the linked repro repo causes my KeyVault (and storage) resource to report "Failed to provision" with the below error log. Running that exact command in the devcontainer terminal manually gives me a valid json (no errors). Stopping and re-running `aspire run` will make provisions succeed.. Rebuilding the container will make the issue re-appear on first launch. It doesn't matter if I enter my subscription details in the dashboard when prompted or have them in appsettings.
Is there a way to see what exactly the failing build command is reporting when aspire runs it? `--debug` doesn't show anything more.
Error:
```
Provisioning kv-hgfse-dev-swc...
Error provisioning kv-hgfse-dev-swc.
System.InvalidOperationException: Command /usr/bin/az bicep build --file "/tmp/aspireAtvhZB/kv-hgfse-dev-swc.module.bicep" --stdout returned non-zero exit code 1
at Aspire.Hosting.Azure.Provisioning.Internal.BicepCliCompiler.ExecuteCommand(ProcessSpec processSpec) in /_/src/Aspire.Hosting.Azure/Provisioning/Internal/BicepCompiler.cs:line 62
at Aspire.Hosting.Azure.Provisioning.Internal.BicepCliCompiler.ExecuteCommand(ProcessSpec processSpec) in /_/src/Aspire.Hosting.Azure/Provisioning/Internal/BicepCompiler.cs:line 69
at Aspire.Hosting.Azure.Provisioning.Internal.BicepCliCompiler.CompileBicepToArmAsync(String bicepFilePath, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Azure/Provisioning/Internal/BicepCompiler.cs:line 47
at Aspire.Hosting.Azure.Provisioning.BicepProvisioner.GetOrCreateResourceAsync(AzureBicepResource resource, ProvisioningContext context, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs:line 146
at Aspire.Hosting.Azure.AzureProvisioner.ProcessResourceAsync(IConfiguration configuration, Lazy`1 provisioningContextLazy, ValueTuple`2 resource, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Azure/Provisioning/Provisioners/AzureProvisioner.cs:line 240
```
Contents of the file that fails the build command:
```bicep
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location
resource kv_hgfse_dev_swc 'Microsoft.KeyVault/vaults@2024-11-01' = {
name: take('kvhgfsedevswc-${uniqueString(resourceGroup().id)}', 24)
location: location
properties: {
tenantId: tenant().tenantId
sku: {
family: 'A'
name: 'standard'
}
enableSoftDelete: true
enableRbacAuthorization: true
enablePurgeProtection: true
}
tags: {
'aspire-resource-name': 'kv-hgfse-dev-swc'
}
}
output vaultUri string = kv_hgfse_dev_swc.properties.vaultUri
output name string = kv_hgfse_dev_swc.name
```
Results of when I manually run the command on that exact file:
```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.38.33.27573",
"templateHash": "4005129244757812078"
}
},
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The location for the resource(s) to be deployed."
}
}
},
"resources": [
{
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2024-11-01",
"name": "[take(format('kvhgfsedevswc-{0}', uniqueString(resourceGroup().id)), 24)]",
"location": "[parameters('location')]",
"properties": {
"tenantId": "[tenant().tenantId]",
"sku": {
"family": "A",
"name": "standard"
},
"enableSoftDelete": true,
"enableRbacAuthorization": true,
"enablePurgeProtection": true
},
"tags": {
"aspire-resource-name": "kv-hgfse-dev-swc"
}
}
],
"outputs": {
"vaultUri": {
"type": "string",
"value": "[reference(resourceId('Microsoft.KeyVault/vaults', take(format('kvhgfsedevswc-{0}', uniqueString(resourceGroup().id)), 24)), '2024-11-01').vaultUri]"
},
"name": {
"type": "string",
"value": "[take(format('kvhgfsedevswc-{0}', uniqueString(resourceGroup().id)), 24)]"
}
}
}
```
### Expected Behavior
_No response_
### Steps To Reproduce
https://github.com/jrunestone/aspireissue1
Clone, open vscode and reopen in container, az login, aspire run, enter subscription details.
Only added this keyvault stuff to the default Aspire template:
```
builder
.AddAzureKeyVault("kv-hgfse-dev-swc")
.ConfigureInfrastructure(cfg =>
{
var kv = cfg.GetProvisionableResources().OfType().Single();
kv.Name = "kv-hgfse-dev-swc";
kv.Properties.EnablePurgeProtection = true;
kv.Properties.EnableSoftDelete = true;
});
```
### Exceptions (if any)
_No response_
### .NET Version info
.NET SDK:
Version: 9.0.306
Commit: cc9947ca66
Workload version: 9.0.300-manifests.87361a52
MSBuild version: 17.14.28+09c1be848
Runtime Environment:
OS Name: debian
OS Version: 12
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/9.0.306/
.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.10
Architecture: x64
Commit: e1f19886fe
.NET SDKs installed:
9.0.306 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
### Anything else?
Aspire 9.5.1
Podman
Vscode
devcontainer
Contributor guide
Assessment
This issue has not been assessed yet.