Hello Omer Ben Aderet ,
It looks like you're having trouble with your Service Principal not being able to list Savings Plans and Reservations despite having the Billing Account Contributor role. This can be a common issue due to the specific permissions needed for accessing Savings Plans, which are managed at the tenant level.
Here's what you should try:
- Assign the Correct Role: The Service Principal needs the "Savings Plan Reader" role assigned at the scope of
/providers/Microsoft.BillingBenefits. The Billing Account Contributor or other subscription roles do not grant the necessary permissions to read Savings Plans. You can assign the Savings Plan Reader role using the Azure CLI with the following command:az role assignment create \
--assignee-object-id <ObjectId>
--assignee-principal-type ServicePrincipal
--role "Savings plan Reader"
--scope "/providers/Microsoft.BillingBenefits"
Make sure to replace `<ObjectId>` with the actual Object ID of your Service Principal.
**Refresh Credentials**: After you've assigned the role, make sure to refresh credentials and re-login using your Service Principal:
```powershell
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
Retry the Command: After logging in again, try running the command to list Savings Plans:
az billing-benefits savings-plan list
Important Notes:
The Savings Plans are considered tenant-level resources, and users or service principals need to be assigned the appropriate Savings Plan RBAC roles to access them. Simply having the Service Principal visible in the IAM panel doesn’t guarantee the necessary permissions to read Savings Plans.
I hope this points you in the right direction! If you’re still facing issues after trying the above steps, please provide more details about any error messages you receive or the current permissions set for the Service Principal.
References:
Permissions to view and manage Azure savings plans Assign Azure roles using the Azure portal Understanding Microsoft Customer Agreement administrative roles in Azure Managing Azure Enterprise Agreement roles
Let me know if you need further help!