Skip to content

fix(azure): register Microsoft.BillingBenefits RP via IaC + runtime ensure (closes #752) - #759

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/752-billingbenefits-register
May 27, 2026
Merged

fix(azure): register Microsoft.BillingBenefits RP via IaC + runtime ensure (closes #752)#759
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/752-billingbenefits-register

Conversation

@cristim

@cristim cristim commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

Closes #752 in two complementary layers:

IaC layer (commit 1): adds Microsoft.BillingBenefits/register/action to the CUDly custom role in both the ARM template (arm/CUDly-CrossSubscription/template.json) and the Terraform module (terraform/modules/iam/azure/cudly-reservation-role/main.tf), so the managed identity has permission to register the RP.

Runtime layer (commit 2): CUDly now actually calls the ARM providers register endpoint on first Savings Plan purchase:

  • Extracts the existing Microsoft.Capacity inline registration logic from services/compute into a shared providers/azure/internal/resourceproviders.EnsureRegistered helper (GET check then POST register, parameterised on namespace + api-version).
  • Refactors services/compute to call the shared helper (no behaviour change).
  • Adds ensureBillingBenefitsProviderRegistered to services/savingsplans.Client -- a sync.Once-guarded call to EnsureRegistered with namespace="Microsoft.BillingBenefits" and api-version=2022-11-01 (GA version for savings plan orders) -- invoked at the top of PurchaseCommitment.

Tests added

  • internal/resourceproviders: already-registered (no POST fired), not-registered (POST fired), GET failure (error includes namespace), POST failure (error includes namespace), token failure, nil cred skip.
  • services/savingsplans: registration GET fires before BeginCreate, not-registered triggers register POST, registration GET issued only once per client lifetime across multiple purchases.

Test plan

  • go test ./providers/azure/... passes (669 tests, all green)
  • terraform validate clean on terraform/modules/iam/azure/cudly-reservation-role
  • On a subscription where Microsoft.BillingBenefits is not pre-registered, purchasing a Savings Plan via CUDly triggers the registration without a 409 MissingSubscriptionRegistration

@cristim cristim added priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience bug Something isn't working triaged Item has been triaged labels May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 34 minutes and 18 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: af4e7b55-7666-4223-a749-b0573a9e5057

📥 Commits

Reviewing files that changed from the base of the PR and between 3931e9e and 09785ee.

📒 Files selected for processing (2)
  • arm/CUDly-CrossSubscription/template.json
  • terraform/modules/iam/azure/cudly-reservation-role/main.tf
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/752-billingbenefits-register

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim

cristim commented May 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…closes #752)

SP-virgin subscriptions 409 with MissingSubscriptionRegistration on the first
Savings Plan order because the Microsoft.BillingBenefits resource provider is
not auto-registered. Adding Microsoft.BillingBenefits/register/action to the
custom role lets CUDly register the RP on first use without requiring the
customer to pre-register it manually via az provider register.
@cristim
cristim force-pushed the fix/752-billingbenefits-register branch from cea0f00 to 09785ee Compare May 27, 2026 17:16
@cristim

cristim commented May 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 3249775 into feat/multicloud-web-frontend May 27, 2026
4 checks passed
@cristim cristim changed the title fix(iac/azure): register Microsoft.BillingBenefits RP via custom role (closes #752) fix(azure): register Microsoft.BillingBenefits RP via IaC + runtime ensure (closes #752) May 27, 2026
@cristim

cristim commented May 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Labels

bug Something isn't working impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant