Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opencost fails to download Price Sheet from Azure #2601

Open
kaitimmer opened this issue Mar 1, 2024 · 4 comments
Open

Opencost fails to download Price Sheet from Azure #2601

kaitimmer opened this issue Mar 1, 2024 · 4 comments
Labels
E2 Estimated level of Effort (1 is easiest, 4 is hardest) needs-follow-up needs-triage opencost OpenCost issues vs. external/downstream P2 Estimated Priority (P0 is highest, P4 is lowest)

Comments

@kaitimmer
Copy link
Contributor

Describe the bug

Opencost fails to download the Azure Price Sheet.

I'm having issues with downloading the Azure Price Sheet:

│ 2024-03-01T15:07:38.025963505Z ERR Error downloading Azure price sheet: getting download URL: beginning pricesheet download: GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts//provid │
│ ers/Microsoft.Billing/billingAccounts/xxx/billingPeriods/202403/providers/Microsoft.Consumption/pricesheets/download             │
│ --------------------------------------------------------------------------------                                                                                                                                  │
│ RESPONSE 403: 403 Forbidden                                                                                                                                                                                       │
│ ERROR CODE: AuthorizationFailed                                                                                                                                                                                   │
│ --------------------------------------------------------------------------------                                                                                                                                  │
│ {                                                                                                                                                                                                                 │
│   "error": {                                                                                                                                                                                                      │
│     "code": "AuthorizationFailed",                                                                                                                                                                                │
│     "message": "The client 'fb3403ef-c807-457a-bc2b-2326788c6294' with object id 'fb3403ef-c807-457a-bc2b-2326788c6294' does not have authorization to perform action 'Microsoft.Billing/billingAccounts/Microsof │
│ t.Billing/xxx/202403/Microsoft.Consumption/download/read' over scope '/providers/Microsoft.Billing/billingAccounts/providers/Mic │
│ rosoft.Billing/billingAccounts/xxx/billingPeriods/202403/providers/Microsoft.Consumption/pricesheets' or the scope is invalid. I │
│ f access was recently granted, please refresh your credentials."                                                                                                                                                  │
│   }                                                                                                                                                                                                               │
│ }                                                                                                                                                                                                                 │

My Opencost "App/ServicePrincipal" does not have the right to read the information.

I tried to use the script, but I only get:

Creating EnrollmentReader role assignment for SP dev-de1-opencost (fb3403ef-c807-457a-bc2b-2326788c6294) in billing account b015b87b-54d3-54ff-5dce-e3b78cfbf1d4:ac5eb31c-e276-4ae2-9f6b-da7f5c42917a_2019-05-31
Role assignment name: 2B95F78F-DD14-4A69-91E6-1A7FF19C49F3
Response: {"code":"UnprocessableEntity","message":"PUT operation is currently supported only on EA billing accounts"}

So, I manually added my Opencost Service principals as "Reader" to my Billing Account.
Screenshot 2024-03-01 at 16 17 45

Still no luck.

What might I be missing here?

Expected behavior

Opencost downloads the Price Sheet and uses it.

Screenshots
If applicable, add screenshots to help explain your problem.

Which version of OpenCost are you using?
1.108.0

@mattray mattray added opencost OpenCost issues vs. external/downstream P2 Estimated Priority (P0 is highest, P4 is lowest) E2 Estimated level of Effort (1 is easiest, 4 is hardest) labels Mar 4, 2024
@mattray
Copy link
Collaborator

mattray commented Mar 4, 2024

@Sean-Holcomb I know you were discussing the Azure Price Sheet recently, did something change or is this a configuration issue?

@Sean-Holcomb
Copy link
Collaborator

I believe this would be @r2k1 domain of expertise, since it appears that id of the service principle matches the id in the error log. It should only be a matter of getting the right permissions applied to that service principle.

@kaitimmer
Copy link
Contributor Author

Anything I can do to help debug this?

@AjayTripathy
Copy link
Contributor

Hi @kaitimmer I'm not an expert here at all but does the READER role actually grant permission for the PUT operation? PUT sounds like it might be more expansive than just read? Response: {"code":"UnprocessableEntity","message":"PUT operation is currently supported only on EA billing accounts"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2 Estimated level of Effort (1 is easiest, 4 is hardest) needs-follow-up needs-triage opencost OpenCost issues vs. external/downstream P2 Estimated Priority (P0 is highest, P4 is lowest)
Projects
None yet
Development

No branches or pull requests

4 participants