Can't connect to azure via Powershell

Handian Sudianto 6,621 Reputation points
2025-11-04T00:51:34.72+00:00

I have this powershell script to connect to Azure and this script is working. But when i run this script in another server why i got below error?

Also when i want to ask about this problem (powershell for azure) to which tag i must select in this post? Currently i use tag Azure and Azure Monitor as child tag.

User's image

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 40,296 Reputation points MVP Volunteer Moderator
    2025-11-04T00:56:23.7866667+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    The error ClientSecretCredential authentication failed and Could not find tenant id for provided tenant domain indicates that your PowerShell session on the second server cannot authenticate the service principal against Azure AD.

    Here are the most common causes:

    1. Tenant or App mismatch : The tenantId, appId, and secret combination does not belong to the same AAD tenant. Double check that the service principal was created in the same tenant as the subscription.
    2. Firewall / proxy issue : The 2nd server may be behind a proxy or firewall that blocks outbound requests to Azure login endpoints (login.microsoftonline.com).
    3. Ensure the server has the latest Az PowerShell module
    4. Verify the SPN has at least Reader/Contributor access to the target subscription-If it fails, the service principal does not exist in that tenant.

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.