Terraform with AZ suddenly stopped working

Tajdar Jawaid 21 Reputation points
2022-01-02T17:36:29.727+00:00

Working with Terraform and AZ Cli.
It was all working fine, but suddenly today Terraform gives me following error.
Also the web session was logged out, which I am able to login back after email code verification, but Terraform however is not able to login through az login (although az login web shows I am looged in successfully, but I get following error on terminal of visual code).

s-iMac:001_StartfromScratch workhorse$ az login
The default web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with az login --use-device-code.

Tried by giving username and password, it is still not working and throwing following error. Tried to reinstall both Terraform and AZ Cli still no luck. Any help will be appreciated.

The following tenants require Multi-Factor Authentication (MFA). Use 'az login --tenant TENANT_ID' to explicitly login to a tenant.
cb357e97-dae6-4a7f-b42f-28c7d5fd8937 'Default Directory'
No subscriptions found for email@ssss .com.
s-iMac:001_StartfromScratch workhorse$ az login -u email@ssss .com -p mypassword
The command failed with an unexpected error. Here is the traceback:
Unable to find wstrust endpoint from MEX. This typically happens when attempting MSA accounts. More details available here. https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Username-Password-Authentication
Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 658, in execute
raise ex
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 721, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 692, in _run_job
result = cmd_copy(params)
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 328, in call
return self.handler(*args, **kwargs)
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/command_modules/profile/custom.py", line 149, in login
subscriptions = profile.login(
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/_profile.py", line 158, in login
user_identity = identity.login_with_username_password(username, password, scopes=scopes, **kwargs)
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/azure/cli/core/auth/identity.py", line 162, in login_with_username_password
result = self._msal_app.acquire_token_by_username_password(username, password, scopes, **kwargs)
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/msal/application.py", line 1401, in acquire_token_by_username_password
response = _clean_up(self._acquire_token_by_username_password_federated(
File "/usr/local/Cellar/azure-cli/2.31.0/libexec/lib/python3.10/site-packages/msal/application.py", line 1423, in _acquire_token_by_username_password_federated
raise ValueError("Unable to find wstrust endpoint from MEX. "
ValueError: Unable to find wstrust endpoint from MEX. This typically happens when attempting MSA accounts. More details available here. https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Username-Password-Authentication
To open an issue, please run: 'az feedback'

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
703 questions
0 comments No comments
{count} votes

Accepted answer
  1. suvasara-MSFT 10,046 Reputation points
    2022-01-17T06:45:40.907+00:00

    @Tajdar Jawaid , From the error it explicitly mentions that you need to login by specifying tenant id as well. Please do try logging in with the following command,

       az login --tenant [tenant id]  
    

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.


1 additional answer

Sort by: Most helpful
  1. Tajdar Jawaid 21 Reputation points
    2022-01-17T11:26:43.25+00:00

    Thanks. The problem has been resolved.

    0 comments No comments

Your answer

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