Skip to content

Azure CLI fails with 400 Bad Request in Cloud Shell for non-supported resource #11386

@mallecespedes

Description

@mallecespedes

Summary

When trying to obtain a token for the Azure API for FHIR using Azure CLI the following error appears:

Command Name
az account get-access-token

Errors:

400 Client Error: Bad Request for url: http://localhost:50342/oauth2/token
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 206, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 603, in execute
    raise ex
cli/core/commands/__init__.py, ln 661, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
...
python3.6/site-packages/msrestazure/azure_active_directory.py, ln 486, in get_msi_token
    result.raise_for_status()
python3.6/site-packages/requests/models.py, ln 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:50342/oauth2/token

To Reproduce:

Open Azure CLI from Azure Portal or sign in with https://shell.azure.com
Execute following command in CLI:
token=$(az account get-access-token --resource=https://azurehealthcareapis.com | jq -r .accessToken)

Expected Behavior

Save access token in the variable named token for further use. The next step according to the documentation https://docs.microsoft.com/en-us/azure/healthcare-apis/get-healthcare-apis-access-token-cli is:
curl -X GET --header "Authorization: Bearer $token" https://<FHIR ACCOUNT NAME>.azurehealthcareapis.com/Patient

Environment Summary

Linux-4.15.0-1063-azure-x86_64-with-debian-stretch-sid
Python 3.6.5
Shell: bash
azure-cli 2.0.77
Extensions:
healthcareapis 0.1.2

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions