Azure / Azure/bicep-types-az

Bicep interacting with BillingSubscriptions & BillingSubscriptionAliases - adding/altering CostCenter

Open
#2,086 1 comment 0 reactions 0 assignees View on GitHub
Billing Service Attention
Dominant language
TypeScript
Stars
108
Forks
44
Avg merge
18h 53m
Merged PRs (30d)
29

Description

**Bicep version**
0.25.53

**Describe the bug**
Trying to at all figure out a way to change CostCenter on an existing Subscription

**To Reproduce**
```bicep
targetScope = 'tenant'

resource billingAccount 'Microsoft.Billing/billingAccounts@2020-05-01' existing = {
name: 'redacted billing account number'
}

resource billingSubAlias 'Microsoft.Billing/billingAccounts/billingSubscriptionAliases@2021-10-01' = {
name: 'redacted subscription id'
parent: billingAccount
properties: {
consumptionCostCenter: 'IDK'
}
}
```
This results in authorization error over scope '/providers/Microsoft.Resources/deployments/what' even though the account has privs to perform Cost Center change operation via the Portal.
The documentation is scarce and difficult to find on how to interact with objects in Billing areas, and how those objects relate to existing subscriptions.

**Additional context**
In an attempt to figure out how this at all could work, we tried retrieving the data by other means in hopes we could see the connections in there and then try to translate them to Bicep.

Going to - Cost Center in the Cost Management + Billing > Selecting Billing Scope > Products + Services > Azure subscriptions
allows for changing the Cost Center in the context menu for each sub using the "Update cost center" option.
That in turn calls the following url/provider using PATCH:

https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountNumber}/billingSubscriptions/{subscriptionId}?api-version=2020-12-15-privatepreview

When calling GET on that specific url, seems like proper data is being returned, but that particular API Version is not even documented since I presume it's Private Preview - yet it is being used in the portal. Getting random errors about API versions not being supported if I try any non "privatepreview" ones.

If I mistype the API version I get "The supported api-versions are '2018-11-01-preview,2019-10-01-preview,2020-05-01,2020-11-01-privatepreview,2020-12-15-privatepreview,2021-10-01,2022-10-01-privatepreview'."

https://learn.microsoft.com/en-us/rest/api/billing/billing-subscriptions/get?view=rest-billing-2021-10-01&tabs=HTTP - this document doesn't seem to have all of those documented, even if we take privatepreview out of the equation. Also the documentation seems to imply that at least a few of those should work and they don't seem to since again, proper results are at all only being produced by "privatepreview" versions

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the tenant-scope Bicep example for Microsoft.Billing billingSubscriptionAliases and compare it with the portal's PATCH request to the billingSubscriptions endpoint. Check the linked Billing REST documentation and supported API-version list; done should clarify whether CostCenter changes are supported through Bicep and document the correct resource and API usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.