def get_subscription_from_cli(name=None):
home = os.path.expanduser('<STR_LIT>')<EOL>azure_profile_path = home + os.sep + '<STR_LIT>' + os.sep + '<STR_LIT>'<EOL>if os.path.isfile(azure_profile_path) is False:<EOL><INDENT>print('<STR_LIT>' +<EOL>azure_profile_path)<EOL>return None<EOL><DEDENT>with io.open(azure_profile_path, '<STR_LIT:r>', encoding='<STR_LIT>') as azure_profile_fd:<EOL><INDENT>azure_profile = json.load(azure_profile_fd)<EOL><DEDENT>for subscription_info in azure_profile['<STR_LIT>']:<EOL><INDENT>if (name is None and subscription_info['<STR_LIT>'] is True) orsubscription_info['<STR_LIT:name>'] == name:<EOL><INDENT>return subscription_info['<STR_LIT:id>']<EOL><DEDENT><DEDENT>return None<EOL>
Get the default, or named, subscription id from CLI's local cache.

    Args:
        name (str): Optional subscription name. If this is set, the subscription id of the named
           subscription is returned from the CLI cache if present. If not set, the subscription id
           of the default subscription is returned.

    Returns:
        Azure subscription ID string.

    Requirements:
        User has run 'az login' once, or is in Azure Cloud Shell.