microsoft / microsoft/aspire

When using azd infra generate with PublishAsAzureContainerApp, bicep module and param files are in split locations and point to incorrect file paths

Open
#10,488 8 comments 2 reactions 0 assignees View on GitHub
area-integrations azure
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

I recently added PublishAsAzureContainerApp to my AppHost project in order to configure specific settings for certain services that are deployed.

However, when using azd infra generate, it generates the appropriate files, it just doesn't put them in the correct places. I'll post an example of my current file structure:

infra/
├── main.bicep
├── main.parameters.json
├── resources.bicep
├── core-service/
│ └── core-service.module.bicep
├── core-service-identity/
│ └── core-service-identity.module.bicep
├── core-service-roles-server-sql/
│ └── core-service-roles-ourservice-sql.module.bicep

aspire/OurSolution.Aspire.AppHost/infra/
├── core-service/
│ └── core-service.tmpl.bicepparam

(other files in root)
azure.yaml
OurSolution.sln

The generated .bicepparam files use a 'using './core-service.module.bicep' reference at the top - a reference to a file that does not exist (or rather, is in a different location).

Here's the output of the azd infra generate command:

azd infra generate
Warning: The following files would be overwritten by generated versions:
* aspire\OurService.Aspire.AppHost\infra\core-service\core-service.tmpl.bicepparam
* infra\core-service\core-service.module.bicep
* infra\core-service-identity\core-service-identity.module.bicep
* infra\core-service-roles-ourservice-sql\core-service-roles-ourservice-sql.module.bicep
* infra\main.bicep
* infra\main.parameters.json
* infra\ourservice-sql\ourservice-sql.module.bicep
* infra\resources.bicep
? What would you like to do with these files? Keep my existing files unchanged

### Expected Behavior

The problem with this is that the .bicepparam files that are generated require that the module.bicep files be in the same infra folder as themselves.

The workaround is to manually move the generated files into the same folder as the .bicepparam files after generation.

### Steps To Reproduce

Create a project that matches our project's file structure, initialize a new .NET project via aspire, then add .PublishAsAzureContainerApp with any config (like CPU/Memory) to its configuration. Then, run azd infra generate.

### Exceptions (if any)

This worked well enough when we were using the previously generated .tmpl.yaml files that are generated when PublishAsAzureContainerApp is not used, because that all is contained in a single file (even though it was in a separate infra folder location).

### .NET Version info

9.0.301

### Anything else?

.NET Aspire version 9.3.2
.NET 9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.