Adds support to rad deploy for deploying a remote Bicep or JSON file over https - #12676
Adds support to rad deploy for deploying a remote Bicep or JSON file over https#12676zachcasper wants to merge 7 commits into
Conversation
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
There was a problem hiding this comment.
Pull request overview
This PR extends the rad deploy CLI workflow to accept remote http(s) URLs for Bicep/ARM templates by downloading them to a temporary local file, ensuring Bicep extension resolution works by writing an adjacent bicepconfig.json, and then compiling/deploying as usual.
Changes:
- Add remote-URL handling to Bicep template preparation (download to temp dir, write
bicepconfig.json, build/deploy). - Update
rad deployhelp text with remote URL support and an example. - Export the default versioned Bicep config generator for reuse and add unit tests for URL/template download behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pkg/cli/bicep/types.go |
Adds remote URL detection + download-to-temp flow and writes a bicepconfig.json next to downloaded .bicep templates. |
pkg/cli/bicep/types_test.go |
Adds unit tests for URL detection, download outcomes, config discovery, and remote ARM JSON handling. |
pkg/cli/cmd/deploy/deploy.go |
Updates command help text and examples to document remote template URLs and limitations. |
pkg/cli/setup/application.go |
Exports the versioned default bicepconfig.json generator so other packages can reuse it. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12676 +/- ##
==========================================
+ Coverage 54.20% 54.32% +0.11%
==========================================
Files 770 770
Lines 51085 51240 +155
==========================================
+ Hits 27690 27835 +145
- Misses 20789 20792 +3
- Partials 2606 2613 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Functional Tests - corerp-cloud30 tests 29 ✅ 23m 49s ⏱️ Results for commit 8f59a99. ♻️ This comment has been updated with latest results. |
…harden tests - Cap remote template downloads with io.LimitReader (maxRemoteTemplateSize) to avoid unbounded memory use from a large or malicious response. - Wrap remote .json read failures to include the original URL for clearer diagnostics. - Make Test_downloadTemplate_Success hermetic (isolated working dir) so it exercises the fallback bicepconfig path deterministically. - Add tests for the working-dir config copy path, size cap, remote JSON URL wrapping, and filesystem-error branches in downloadTemplate/writeBicepConfig. Signed-off-by: Zach Casper <zachcasper@microsoft.com>
- Classify remote URLs by http(s) prefix and reject malformed/no-host URLs instead of misreading them as local paths. - Redact userinfo and query values in all logged/surfaced URLs so credentials are not leaked. - Make the HTTP client injectable, build requests with the caller's context, and refuse https->http redirect downgrades. - Retry transient download failures (transport errors, 5xx, 429) within the overall timeout, honoring Retry-After; never retry 4xx. - Reject text/html responses so a GitHub page URL yields a clear error instead of a confusing parser failure. - Thread context.Context through the Bicep.PrepareTemplate interface and all callers. Signed-off-by: Zach Casper <zachcasper@microsoft.com>
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Summary
Adds support for deploying a remote Bicep or ARM template by URL with
rad deploy. The template argument may now be anhttp(s)URL in addition to a local path; the remote file is downloaded, then read (ARM JSON) or compiled (Bicep) and deployed, mirroring the behavior users expect from tools likekubectl. Existing local.bicep/.jsonworkflows are unchanged.Because Bicep discovers
bicepconfig.jsonby walking up from the template's directory, a downloaded template placed in an isolated temp dir would fail to resolve extension declarations such asextension radius. To handle this, abicepconfig.jsonis written next to the downloaded template — reusing the nearest one found by searching upward from the working directory, and otherwise falling back to the default Radius extensions config.Remote downloads are bounded by a maximum size to avoid unbounded memory use from a large or malicious response, and remote read/parse failures include the original URL for clearer diagnostics.
Reason for change
rad deploypreviously treated its template argument as a local filesystem path only. Users want to deploy templates directly from a URL (e.g. a recipe pack inresource-types-contrib) without downloading them first.Fixes #12673
How to test
Unit tests:
Manual:
rad deploy https://<host>/template.bicep— resolves, compiles, and deploys.bicepconfig.jsonto reuse it; run from a directory without one to confirm the default Radius config is used.rad deploy https://<host>/template.json— remote ARM JSON works.rad deploy ./local.bicepand./local.json— local behavior unchanged..bicep/.jsonURL, unreachable host, a template exceeding the maximum download size, and invalid remote JSON (error names the URL).File change summary
pkg/cli/bicep/types.goPrepareTemplateto accepthttp(s)URLs: download the template to a temp file (size-bounded viaio.LimitReader), write abicepconfig.jsonalongside it so extensions resolve, then read/compile and clean up. Remote read/parse errors are wrapped with the source URL. Adds helpersisRemoteURL,downloadTemplate,writeBicepConfig, andfindBicepConfig.pkg/cli/cmd/deploy/deploy.gopkg/cli/setup/application.gogetVersionedBicepConfigasGetVersionedBicepConfigso the bicep package can reuse the default config generator.pkg/cli/bicep/types_test.gohttptest) covering URL detection, download success/404/unsupported-extension/connection-failure, max-size enforcement,bicepconfig.jsondiscovery/copy/fallback, filesystem-error branches (MkdirTemp/WriteFile/ReadFile), remote ARM JSON handling, and remote JSON errors including the URL.