I am trying to run terraform plan -var-file=C:\dev\terraform.tfvars
. It's throwing an error Subnet (Subscription) was not found
.
Okay, I tried az login
, webbrowser was automatically opened and wrote: You have logged into Microsoft Azure!
.
However in powershell I see:
Failed to authenticate d0df3d96-c065 'test' due to error 'AADSTS500213: The resource tenant's cross-tenant access policy does not allow this user to access this tenant. Trace ID: 65631f19-c4f6 Correlation ID: 536c20e9-1c50 Timestamp: 2025-03-06 14:06:27Z'
Failed to authenticate d4e6f657-4208 'now' due to error 'AADSTS500021: Access to 'now' tenant is denied. Trace ID: 8209bdc9-3736 Correlation ID: 8b715edb-3f5e Timestamp: 2025-03-06 14:06:30Z'
however in Azure Portal I can click and manually create e.g Azure Storage Account.
I am trying to run terraform plan -var-file=C:\dev\terraform.tfvars
. It's throwing an error Subnet (Subscription) was not found
.
Okay, I tried az login
, webbrowser was automatically opened and wrote: You have logged into Microsoft Azure!
.
However in powershell I see:
Failed to authenticate d0df3d96-c065 'test' due to error 'AADSTS500213: The resource tenant's cross-tenant access policy does not allow this user to access this tenant. Trace ID: 65631f19-c4f6 Correlation ID: 536c20e9-1c50 Timestamp: 2025-03-06 14:06:27Z'
Failed to authenticate d4e6f657-4208 'now' due to error 'AADSTS500021: Access to 'now' tenant is denied. Trace ID: 8209bdc9-3736 Correlation ID: 8b715edb-3f5e Timestamp: 2025-03-06 14:06:30Z'
however in Azure Portal I can click and manually create e.g Azure Storage Account.
Failed to authenticate due to errors AADSTS500213 & AADSTS500021
Here as per the error description I can see two different authentication issue as per the error description which are related permissions cross-tenant access policy issue while trying to authenticate with Azure via az login
AADSTS500021 – Access to ‘{tenant}’ tenant is denied
The particular blocker occurs when there is any restriction applied to tenant to access.
Which means an active Restrict-Access-To-Tenants policy was enabled which blocking the users to access that particular tenant.
Refer:
https://learn.microsoft/en-us/answers/questions/2201407/diagnosing-and-fixing-aadsts500021
https://learn.microsoft/en-us/entra/identity/enterprise-apps/tenant-restrictions
https://learn.microsoft/en-us/entra/identity-platform/reference-error-codes#:%7E:text=Access%20to%20%27%7Btenant%7D%27,%2DAccess%2DTo%2DTenant%20.
AADSTS500213 – The resource tenant’s cross-tenant access policy does not allow this user to access this tenant
These blockers happen when cross-tenant access policies prevent authentication for the particular user belongs to one tenant tries to access the other.
The possible cases for these when you try to access into wrong tenant unintentionally.
If you previously had access and now don’t, the cross-tenant access settings might have been changed.
&
az login --tenant <your-tenant-id>
If you're using any SP, then specify it as mentioned below
az login --service-principal -u <app-id> -p <password> --tenant <tenant-id>
Refer:
https://learn.microsoft/en-us/answers/questions/1340306/unable-to-access-one-of-our-b2c-tenants-from-main