Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
80 stars 26 forks source link

Bicep interacting with BillingSubscriptions & BillingSubscriptionAliases - adding/altering CostCenter #2086

Open JakubLizinczyk opened 4 months ago

JakubLizinczyk commented 4 months ago

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

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

microsoft-github-policy-service[bot] commented 4 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @cabbpt. Please see https://aka.ms/biceptypesinfo for troubleshooting help.