Fix Azure provider scope construction for v20250801preview API#11440
Fix Azure provider scope construction for v20250801preview API#11440
Conversation
The setupCloudProviders function in deploy.go incorrectly constructed
the Azure scope as '/planes/azure/azure/Subscriptions/{id}/ResourceGroups/{rg}'
instead of the correct format '/subscriptions/{id}/resourceGroups/{rg}'.
This caused deployment failures with "Subscription is required for azure scope"
errors because downstream scope parsing expected lowercase 'subscriptions'
and no '/planes/azure/azure/' prefix.
Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11440 +/- ##
==========================================
+ Coverage 51.22% 51.24% +0.01%
==========================================
Files 699 699
Lines 44062 44065 +3
==========================================
+ Hits 22572 22581 +9
+ Misses 19330 19327 -3
+ Partials 2160 2157 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
There was a problem hiding this comment.
Pull request overview
Fixes Azure provider scope construction in the CLI deploy runner for Radius.Core/environments@2025-08-01-preview (v20250801preview) so downstream scope parsing (FindScope("subscriptions")) succeeds.
Changes:
- Update
setupCloudProviders()to emit ARM-style Azure scopes (/subscriptions/.../resourceGroups/...) forv20250801preview. - Update deploy command test expectations to match the corrected Azure scope format.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/cli/cmd/deploy/deploy.go | Adjusts Azure scope string construction for v20250801preview environment properties. |
| pkg/cli/cmd/deploy/deploy_test.go | Updates test expectations for Azure scope format in deploy provider setup/configure tests. |
You can also share your feedback on Copilot code review. Take the survey.
| }, | ||
| expectedAzure: &clients.AzureProvider{ | ||
| Scope: "/planes/azure/azure/Subscriptions/test-subscription/ResourceGroups/test-rg", | ||
| Scope: "/subscriptions/test-subscription/resourceGroups/test-rg", | ||
| }, |
There was a problem hiding this comment.
Added a test case for v20250801preview with only SubscriptionID set (nil ResourceGroupName), verifying the subscription-only scope /subscriptions/test-subscription is produced without panic. See commit 5e03749.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
… ResourceGroupName) Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
|
Ready for review, I've verified that the changes fix the bug in my local build: |
Description
setupCloudProviders()in the deploy runner constructed the Azure scope incorrectly forv20250801preview, producing/planes/azure/azure/Subscriptions/{id}/ResourceGroups/{rg}instead of/subscriptions/{id}/resourceGroups/{rg}.Three bugs in one line:
/planes/azure/azure/prefixSubscriptionsinstead ofsubscriptionsResourceGroupsinstead ofresourceGroupsDownstream
resources.Parse()+FindScope("subscriptions")failed to match, causing"Subscription is required for azure scope"errors on every deploy with this API version.Additionally,
ResourceGroupNameis optional in v20250801preview (*string). The scope is now built conditionally: subscription-only scope (/subscriptions/{id}) is produced whenResourceGroupNameis nil or empty, preventing a nil pointer dereference.Test expectations updated to match, and a new test case added for the subscription-only scope scenario.
Type of change
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.