Skip to content

Adds support to rad deploy for deploying a remote Bicep or JSON file over https - #12676

Open
zachcasper wants to merge 7 commits into
radius-project:mainfrom
zachcasper:rad-deploy-url
Open

Adds support to rad deploy for deploying a remote Bicep or JSON file over https#12676
zachcasper wants to merge 7 commits into
radius-project:mainfrom
zachcasper:rad-deploy-url

Conversation

@zachcasper

@zachcasper zachcasper commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for deploying a remote Bicep or ARM template by URL with rad deploy. The template argument may now be an http(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 like kubectl. Existing local .bicep/.json workflows are unchanged.

Because Bicep discovers bicepconfig.json by walking up from the template's directory, a downloaded template placed in an isolated temp dir would fail to resolve extension declarations such as extension radius. To handle this, a bicepconfig.json is 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 deploy previously treated its template argument as a local filesystem path only. Users want to deploy templates directly from a URL (e.g. a recipe pack in resource-types-contrib) without downloading them first.

Fixes #12673

How to test

Unit tests:

go test ./pkg/cli/bicep/... ./pkg/cli/setup/... ./pkg/cli/cmd/deploy/...

Manual:

  1. rad deploy https://<host>/template.bicep — resolves, compiles, and deploys.
  2. Run from a directory with a valid bicepconfig.json to reuse it; run from a directory without one to confirm the default Radius config is used.
  3. rad deploy https://<host>/template.json — remote ARM JSON works.
  4. rad deploy ./local.bicep and ./local.json — local behavior unchanged.
  5. Error cases each report a clear error: 404 URL, non-.bicep/.json URL, unreachable host, a template exceeding the maximum download size, and invalid remote JSON (error names the URL).

File change summary

File Summary of change
pkg/cli/bicep/types.go Extend PrepareTemplate to accept http(s) URLs: download the template to a temp file (size-bounded via io.LimitReader), write a bicepconfig.json alongside it so extensions resolve, then read/compile and clean up. Remote read/parse errors are wrapped with the source URL. Adds helpers isRemoteURL, downloadTemplate, writeBicepConfig, and findBicepConfig.
pkg/cli/cmd/deploy/deploy.go Document remote-URL support in the command long help and add a remote-URL example.
pkg/cli/setup/application.go Export getVersionedBicepConfig as GetVersionedBicepConfig so the bicep package can reuse the default config generator.
pkg/cli/bicep/types_test.go New unit tests (using httptest) covering URL detection, download success/404/unsupported-extension/connection-failure, max-size enforcement, bicepconfig.json discovery/copy/fallback, filesystem-error branches (MkdirTemp/WriteFile/ReadFile), remote ARM JSON handling, and remote JSON errors including the URL.

Signed-off-by: Zach Casper <zachcasper@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 deploy help 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.

Comment thread pkg/cli/bicep/types.go Outdated
Comment thread pkg/cli/bicep/types.go
Comment thread pkg/cli/bicep/types_test.go
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.55422% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.32%. Comparing base (a25786d) to head (7281b73).

Files with missing lines Patch % Lines
pkg/cli/bicep/types.go 88.31% 14 Missing and 4 partials ⚠️
pkg/cli/cmd/bicep/publish/publish.go 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

Functional Tests - corerp-cloud

30 tests   29 ✅  23m 49s ⏱️
 2 suites   1 💤
 1 files     0 ❌

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>
@zachcasper zachcasper changed the title Adds support for deploying a remote Bicep or JSON template using rad deploy over https Adds support to rad deploy for deploying a remote Bicep or JSON file over https Aug 14, 2026
@zachcasper
zachcasper marked this pull request as ready for review August 14, 2026 13:34
@zachcasper
zachcasper requested review from a team as code owners August 14, 2026 13:34

@brooke-hamilton brooke-hamilton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment thread pkg/cli/bicep/types.go
Comment thread pkg/cli/bicep/types.go Outdated
Comment thread pkg/cli/bicep/types.go Outdated
Comment thread pkg/cli/bicep/types.go Outdated
Comment thread pkg/cli/bicep/types.go Outdated
- 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>
@zachcasper
zachcasper enabled auto-merge August 14, 2026 21:31
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
Signed-off-by: Zach Casper <zachcasper@microsoft.com>
@radius-functional-tests

radius-functional-tests Bot commented Aug 14, 2026

Copy link
Copy Markdown

Radius functional test overview

🔍 Go to test action run

Click here to see the test run details
Name Value
Repository zachcasper/radius
Commit ref 7281b73
Unique ID funcdde5e74713
Image tag pr-funcdde5e74713
  • Dapr: 1.14.4
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcdde5e74713
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcdde5e74713
  • dynamic-rp test image location: ghcr.io/radius-project/dev/dynamic-rp:pr-funcdde5e74713
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcdde5e74713
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcdde5e74713
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ ucp-cloud functional tests succeeded
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
✅ corerp-cloud functional tests succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded
❌ corerp-cloud functional test failed. Please check the logs for more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support remote Bicep template URLs in rad deploy

3 participants