def _ParseCredentialsFile(profile_name: str) -> Dict[str, Any]:
  """Parse Azure credentials.json file.

  Args:
    profile_name (str): A name for the Azure account information to retrieve.
        The .json file should have the following format:

        {
          'profile_name': {
              'subscriptionId': xxx,
              'tenantId': xxx,
              'clientId': xxx,
              'clientSecret': xxx
          },
          'other_profile_name': {
              'subscriptionId': yyy,
              'tenantId': yyy,
              'clientId': yyy,
              'clientSecret': yyy
          },
          ...
        }

        Note that you can specify several profiles that use the same tenantId,
        clientId and clientSecret but a different subscriptionId.
        If you set the environment variable AZURE_CREDENTIALS_PATH to an
        absolute path to the credentials file, then the library will look
        there instead of in ~/.azure/credentials.json.

  Returns:
    Dict[str, str]: A dict containing the required account_info fields.

  Raises:
    CredentialsConfigurationError: If there are environment variables that
        are not set or if the credentials file has missing entries/profiles.
    FileNotFoundError: If the credentials file is not found.
    InvalidFileFormatError: If the credentials file couldn't be parsed.
  """
  path = os.getenv('AZURE_CREDENTIALS_PATH')
  if not path:
    path = os.path.expanduser('~/.azure/credentials.json')

  if not os.path.exists(path):
    raise FileNotFoundError(
        'Credentials file not found. Please place it in '
        '"~/.azure/credentials.json" or specify an absolute path to it in '
        'the AZURE_CREDENTIALS_PATH environment variable.')

  with open(path, encoding='utf-8') as profiles:
    try:
      account_info: Dict[str, Any] = json.load(profiles).get(profile_name)
    except ValueError as exception:
      raise errors.InvalidFileFormatError(
          'Could not decode JSON file. Please verify the file format:'
          ' {0!s}'.format(exception), __name__) from exception
    if not account_info:
      raise errors.CredentialsConfigurationError(
          'Profile name {0:s} not found in credentials file {1:s}'.format(
              profile_name, path), __name__)
    required_entries = ['subscriptionId', 'clientId', 'clientSecret',
                        'tenantId']
    if not all(account_info.get(entry) for entry in required_entries):
      raise errors.CredentialsConfigurationError(
          'Please make sure that your JSON file has the required entries. The '
          'file should contain at least the following: {0:s}'.format(
              ', '.join(required_entries)), __name__)

  return account_info
Parse Azure credentials.json file.

Args:
profile_name (str): A name for the Azure account information to retrieve.
The .json file should have the following format:

{
'profile_name': {
'subscriptionId': xxx,
'tenantId': xxx,
'clientId': xxx,
'clientSecret': xxx
},
'other_profile_name': {
'subscriptionId': yyy,
'tenantId': yyy,
'clientId': yyy,
'clientSecret': yyy
},
...
}

Note that you can specify several profiles that use the same tenantId,
clientId and clientSecret but a different subscriptionId.
If you set the environment variable AZURE_CREDENTIALS_PATH to an
absolute path to the credentials file, then the library will look
there instead of in ~/.azure/credentials.json.

Returns:
Dict[str, str]: A dict containing the required account_info fields.

Raises:
CredentialsConfigurationError: If there are environment variables that
are not set or if the credentials file has missing entries/profiles.
FileNotFoundError: If the credentials file is not found.
InvalidFileFormatError: If the credentials file couldn't be parsed.
libcloudforensics/providers/azure/internal/common.py