question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

using arm-consumption sdk with billingAccountId give 401

See original GitHub issue

Describe the bug When using arm-consumption all request with

const billingAccountId = "123456";

we experiance a 401 answer. We have assigned the role reader on the whole EA portal for the app registration we using.

RestError: No claims present for the caller in the system { "name": "RestError", "code": "401", "statusCode": 401, "request": { "url": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/XXXXX/billingPeriods/202204/providers/Microsoft.Consumption/balances?api-version=2021-10-01", "headers": { "accept": "application/json", "accept-encoding": "gzip,deflate", "user-agent": "azsdk-js-arm-consumption/9.0.1 core-rest-pipeline/1.8.0 Node/v14.19.0 OS/(x64-Darwin-21.3.0)", "x-ms-client-request-id": "xxxxx-xxxx-xxx-xxx-xxxxxxxx", "authorization": "REDACTED" }, "method": "GET", "timeout": 0, "disableKeepAlive": false, "streamResponseStatusCodes": {}, "withCredentials": false, "requestId": "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", "allowInsecureConnection": false, "enableBrowserStreams": false }, "details": { "error": { "code": "401", "message": "No claims present for the caller in the system" } }, "message": "No claims present for the caller in the system"

We are using the example in: https://github.com/Azure/azure-sdk-for-js/blob/aee346be5458df5c81e53dbb09e1a7f3a7b07e1a/sdk/consumption/arm-consumption/samples/v9/typescript/src/balancesGetByBillingAccountSample.ts

And authenticate using @identity sdk.

To Reproduce Steps to reproduce the behavior:

  1. Resgister an application in Azure Portal
  2. Download the example from sdk example https://github.com/Azure/azure-sdk-for-js/blob/aee346be5458df5c81e53dbb09e1a7f3a7b07e1a/sdk/consumption/arm-consumption/samples/v9/typescript/src/balancesGetByBillingAccountSample.ts
  3. Add the tenant, app id and secreat to the project/azure function using the sdk
  4. Give the app reader in the EA portal
  5. Make the request with billingAccountId

Expected behavior Getting balancesGetByBillingAccountSample response as expected in example.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
qiaozhacommented, May 24, 2022

@BoostSebastian, Look like this is a service backend error that related with your billing account. I tried on my side, get another 404 error.

    "error": {
      "code": "404",
      "message": "No billing period information found for the specified Enrollments:XXXXX. (Request ID: XXXXX)"
    }

I guess this is because my offer type doesn’t support this. but not very sure. Maybe you can try to open a support ticket in the portal to get the help from the service team directly. FYI here’s their FAQ https://docs.microsoft.com/en-us/azure/cost-management-billing/cost-management-billing-faq?WT.mc_id=Portal-Microsoft_Azure_Support&product=all

1reaction
qiaozhacommented, May 24, 2022

@qiaozha is this something you can help with?

Yes, I will take a look. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Billing Usage API returns 401 Unauthorized
To acquire Token using AcquireToken() Method, initially I used only Client Id which then asks for User Credentials in login window. However, I...
Read more >
Example question title: Why am I getting a 401 unauthorized?
The 401 unauthorized error is typically due to an invalid (or possibly even missing) access token made in your API request.
Read more >
Receiving unauthorized errors (401) while invoking APIs - Azure
Provides troubleshooting steps to an issue in which you are getting unauthorized errors (401) while invoking APIs.
Read more >
401 Error when attempting to paginate endpoint in Users Api
My application to refresh our database with agent routing and presence is failing on a 401 error that's cryptic to me. Using ......
Read more >
I am trying to get an access token using the ID Key approach. I ...
I have used the signing algorithm indicated in the valence-sdk-dotnet - I keep getting an 401 status code -> unauthorized application.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found