Prerequisites
- An Azure subscription with Owner or User Access Administrator access.
- Permission to create app registrations in Microsoft Entra ID.
- Multi-factor authentication registered on your account. Security defaults block app registration without it.
Reader plus Cost Management Reader covers every read-only agent. Add write-level roles only if you want agents to change Azure resources.
Setup
- Azure CLI
- Azure portal
1
Select the subscription
2
Create the service principal
password is shown once.3
Add cost access
4
Add the connection in CloudThinker
Navigate to Connections → Azure and enter
appId as APP_ID, password as CLIENT_SECRET, and tenant as TENANT_ID. Select AZURE_DEFAULT_REGION, then click Connect.Success state: the connection shows a Connected status.Microsoft Customer Agreement billing
Pay-as-you-go subscriptions bought online use a Microsoft Customer Agreement (MCA). Cost Management answers an MCA subscription withGiven subscription doesn't have valid WebDirect/AIRS offer type, so Optimize reads spend at the billing profile instead.
Grant the service principal access to that scope: go to Cost Management + Billing → your billing account → Billing profiles → your profile → Access control (IAM) → Add, and assign Billing profile reader to the app registration. Subscription role assignments do not cover billing scopes.
Connection details
The subscription is not a connection field. CloudThinker discovers every subscription the service principal can read.
Required permissions
Reader alone returns no cost data. Reader grants
*/read, and a Cost Management query is a POST action that */read does not match.
Agent capabilities
Once connected, agents can analyze and optimize your Azure resources.Verify the connection
Example prompts
Troubleshooting
Sign-in blocked by security defaults
Sign-in blocked by security defaults
az login or the portal returns AADSTS530035: Access has been blocked by security defaults. Security defaults require multi-factor authentication before you can register an app. Register a method at aka.ms/mfasetup and sign in again. The --use-device-code and --allow-no-subscriptions flags do not bypass this.Authentication failed
Authentication failed
Verify APP_ID, CLIENT_SECRET, and TENANT_ID. Check that the secret has not expired and that the app registration lives in the tenant you entered. Confirm no conditional access policy blocks service principal sign-in.
Client secret expired
Client secret expired
Run
az ad sp credential reset --id <appId>, or go to Microsoft Entra ID → App registrations → your app → Certificates & secrets and create a new secret. Update CLIENT_SECRET in the connection.No cost data in Optimize
No cost data in Optimize
Optimize reports Azure Cost Management is not readable. Assign Cost Management Reader on the subscription. If the subscription uses a Microsoft Customer Agreement, also assign Billing profile reader on the billing profile. Role assignments take a few minutes to propagate.
Cost Management returns 429
Cost Management returns 429
A new subscription throttles Cost Management heavily, and the query answers
429 Too many requests. Nothing is misconfigured. Wait a few minutes and reload Optimize.Missing resources
Missing resources
Verify the Reader role is assigned on every subscription you expect to see. Resources in a subscription the service principal cannot read never appear.
Security
- Least privilege — grant only the permissions the agents need for your use case; start read-only and widen later.
- Read-only by default — use read-only credentials unless you want agents to make changes through this connection.
- Rotate credentials — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
- Revoke on offboarding — remove the credential at the provider when you delete a connection or a teammate leaves.
- Set secret expiration — always set an expiration on client secrets, and rotate before expiry.
- Scope the roles — assign Reader and Cost Management Reader on the subscriptions CloudThinker needs, not at management group level by default.
Related
AWS Connection
Connect Amazon Web Services
Oliver Agent
Security-focused agent for Azure compliance