Comments (7)
It tries to fetch the data for the whole of the subscriptions, not on the resourcegroup level. That can be the reason you get the 401, as the scope is subscription.
from azure-cost-cli.
Your registration is correct, but you scope it to a resource group: az ad sp create-for-rbac --name "FinOpsCli" --role "Cost Management Reader" --scopes /subscriptions/Sub-ID1/resourceGroups/FinOpsRG --sdk-auth
so remove the /resourceGroups/FinOpsRG
from it.
And what you are doing is not wrong, but the tool does a call to the api with a scope on the subscription, not on a resource group level (yes, you can query or filter on resource groups, but it will still do the call on the subscription level). I could use a different scope, but for simplicity, it currently operates on subscriptions.
To get the authentication, the tool looks at the default credentials provided, so it will first query the AZ login call. So you can try to log in using the az login
call. See the docs.
from azure-cost-cli.
Good to hear that it works for you. If you have more examples, then please do a PR with them.
from azure-cost-cli.
Thanks for opening your first issue! Reports like these help improve the project!
from azure-cost-cli.
ty! I will try to specify a resource group name
from azure-cost-cli.
@mivano I try with this command azure-cost costByResource -o markdown -s ${{ github.event.inputs.azure-sub-id }} --query "ByResourceGroup["FinOpsRG"].[ResourceGroup, Cost]" --debug >> $GITHUB_STEP_SUMMARY
but I still get the same error Version: 0.32.0.0 Using token credential: ChainedTokenCredential to fetch a token. Fetching cost data for resources... Token retrieved and expires at: 09/01/2023 23:28:50 +00:00 Retrieving data from /subscriptions//providers/Microsoft.CostMana gement/query?api-version=2021-10-01&$top=5000 using the following payload: �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"ActualCost"�[0m�[38;5;8m,�[0m �[38;5;12m"timeframe"�[0m�[38;5;11m:�[0m �[38;5;9m"BillingMonthToDate"�[0m�[38;5;8m,�[0m �[38;5;12m"timePeriod"�[0m�[38;5;11m:�[0m �[38;5;8mnull,�[0m �[38;5;12m"dataSet"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"granularity"�[0m�[38;5;11m:�[0m �[38;5;9m"None"�[0m�[38;5;8m,�[0m �[38;5;12m"aggregation"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"totalCost"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"Cost"�[0m�[38;5;8m,�[0m �[38;5;12m"function"�[0m�[38;5;11m:�[0m �[38;5;9m"Sum"�[0m �[38;5;8m,�[0m �[38;5;12m"totalCostUSD"�[0m�[38;5;11m:�[0m �[38;5;8m�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"CostUSD"�[0m�[38;5;8m,�[0m �[38;5;12m"function"�[0m�[38;5;11m:�[0m �[38;5;9m"Sum"�[0m �[38;5;8m�[0m �[38;5;8m***,�[0m �[38;5;12m"include"�[0m�[38;5;11m:�[0m �[38;5;8m[�[0m �[38;5;9m"Tags"�[0m �[38;5;8m],�[0m �[38;5;12m"filter"�[0m�[38;5;11m:�[0m �[38;5;8mnull,�[0m �[38;5;12m"grouping"�[0m�[38;5;11m:�[0m �[38;5;8m[�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"ResourceId"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"ResourceType"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"ResourceLocation"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"ChargeType"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"ResourceGroupName"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"PublisherType"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"MeterCategory"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"MeterSubcategory"�[0m �[38;5;8m,�[0m �[38;5;8m�[0m �[38;5;12m"type"�[0m�[38;5;11m:�[0m �[38;5;9m"Dimension"�[0m�[38;5;8m,�[0m �[38;5;12m"name"�[0m�[38;5;11m:�[0m �[38;5;9m"Meter"�[0m �[38;5;8m�[0m �[38;5;8m]�[0m �[38;5;8m�[0m �[38;5;8m�[0m Response status code is Unauthorized and got payload size of 156 Response content: "error":"code":"RBACAccessDenied","message":"The client does not have authorization to perform action. Request ID: b72f026f-f1c1-4831-b133-7950fcfefb8a"*** �[38;5;9mError:�[0m Response status code does not indicate success: 401 (Unauthorized).
how do you register the sp to get AZURE_CREDENTIALS? I found this ref https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/assign-roles-azure-service-principals
from azure-cost-cli.
Thank you so much @mivano it work fine now 😊 I remove the scope as you mentioned, still to play with the query parameters, I will try to add more examples to the Query section 😉.
cheers!
from azure-cost-cli.
Related Issues (20)
- Report "dailyCost" by period. HOT 4
- Exclude when filtering HOT 3
- Monthly issue metrics report
- Accessing Government Cloud (High) HOT 15
- timeframe TheLastMonth error HOT 5
- Error when running the command azure-cost dailyCosts -b locally HOT 1
- .net framework 6.0 ? HOT 11
- Monthly issue metrics report
- incorrect value for accumulatedCost report Last 30 days: HOT 3
- incorrect time span for accumulatedCost report last 7 days cost includes 8 days in range HOT 4
- Monthly issue metrics report
- getting 400 error HOT 3
- The grain Hourly not works HOT 3
- Piping the output to a file hides actual errors HOT 3
- Monthly issue metrics report
- Bug - Missing subscription ID. Please specify a subscription ID or login to Azure CLI HOT 2
- Rate limiting not using latest rate-limiting http headers
- Federated credentials HOT 5
- zsh: command not found: azure-cost HOT 2
- Monthly issue metrics report
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-cost-cli.