Conversation
- Convert relative template file paths to absolute in constructor - Copy template files to output directory when directory parameter is provided - Add test to verify bicep resources with template files can be published Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13968Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13968" |
0502f33 to
a7e3a40
Compare
- Don't combine paths if TemplateFile is specified - Add test to verify bicep resources with template files can be published Fix #13967
a7e3a40 to
eaa877c
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where AzureBicepResource with a templateFile parameter failed during Azure publishing with "Could not find file" errors. The issue occurred because GetBicepTemplateFile() incorrectly combined user-provided template file paths with a temporary directory parameter, resulting in invalid file paths when attempting to copy the template files.
Changes:
- Modified
GetBicepTemplateFile()to return the template file path directly whenTemplateFileis specified, instead of combining it with thedirectoryparameter - Added three unit tests to verify the corrected behavior of
GetBicepTemplateFile()with template files vs template strings - Added an integration test to validate end-to-end publishing with relative template file paths
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Aspire.Hosting.Azure/AzureBicepResource.cs | Fixed GetBicepTemplateFile() to return TemplateFile path directly without incorrectly combining it with directory parameter |
| tests/Aspire.Hosting.Azure.Tests/AzureBicepResourceTests.cs | Added three unit tests verifying GetBicepTemplateFile() behavior with template files and strings |
| tests/Aspire.Hosting.Azure.Tests/AzureEnvironmentResourceTests.cs | Added integration test using RemoteExecutor to validate end-to-end publishing with relative template file paths |
|
/backport to release/13.1 |
|
Started backporting to release/13.1: https://github.com/dotnet/aspire/actions/runs/21179320631 |
Description
AzureBicepResourcewith atemplateFileparameter failed duringAzurePublishingContext.WriteModelAsync()with "Could not find file" errors.GetBicepTemplateFile()combined paths without copying the file to the output directoryChanges:
AzureBicepResourceWithTemplateFile_CanBePublishedto validate end-to-end publishing with template filesChecklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.ms/usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepHgBrjy/env-acr.module.bicep --stdout(dns block)/usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicepccCXB9/teststorage.module.bicep --stdout(dns block)/usr/local/bin/bicep /usr/local/bin/bicep build /tmp/aspire-bicep8yq5hz/env.module.bicep --stdout(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>Failed to write Azure Bicep templates: Could not find file with AzurePublishingContext</issue_title>
<issue_description>Using an AzureBicepResource with a template file and using
AzurePublishingContextto publish all the bicep files, results in an exception:Repo steps
aspire do pubilsh-customthe following AppHost:with
front-door-appservice.bicep: