Manjunath M Gowda
Manjunath M Gowda

Reputation: 109

Not able to Access Billing info using Azure CLI

I created a service principal using rbac and using the subscription id and I was able to login and all CLI calls with Azure using this sp and this login

(creating SP az ad sp create-for-rbac -n "AppName1" --role contributor --scopes /subscriptions//resourceGroups/)

But when I call for billing info as: az consumption usage list --subscription Unauthorized. Request ID:

I am not sure what authentication permission scope to add to enable this. Tried too many things and somehow I feel I am not in the right direction. Any help will be greatly appreciated.

Upvotes: 0

Views: 457

Answers (2)

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

I believe the issue is that you assigned the “contributor” role at the resource group level and then trying to access a subscription level resource. Since you don’t have permission for that, you’re getting this “Unauthorized” error.

To fix this, please try to assign the “contributor” role at the subscription level for this service principal.

Upvotes: 1

A Modgil
A Modgil

Reputation: 290

Did you login with the service principle using the following command before hitting the billing/usage?

az login --service-principal -u <app-url> -p <password-or-cert> --tenant <tenant>

Upvotes: 1

Related Questions