def QueryMetrics(args: 'argparse.Namespace') -> None:
  """Query Azure Monitoring metrics for a resource.

  Args:
    args (argparse.Namespace): Arguments from ArgumentParser.

  Raises:
    RuntimeError: If from_date or to_date could not be parsed.
  """
  az_account = account.AZAccount(args.default_resource_group_name)
  az_monitoring = monitoring.AZMonitoring(az_account)
  from_date, to_date = args.from_date, args.to_date
  if from_date and to_date:
    try:
      from_date = datetime.strptime(from_date, '%Y-%m-%dT%H:%M:%SZ')
      to_date = datetime.strptime(to_date, '%Y-%m-%dT%H:%M:%SZ')
    except ValueError as exception:
      raise RuntimeError(
          'Cannot parse date: {0!s}'.format(exception)) from exception
  metrics = az_monitoring.GetMetricsForResource(
      args.resource_id,
      metrics=args.metrics,
      from_date=from_date,
      to_date=to_date,
      interval=args.interval,
      aggregation=args.aggregation or 'Total',
      qfilter=args.qfilter)

  for metric, metric_value in metrics.items():
    logger.info('Metric: {0:s}'.format(metric))
    for timestamp, value in metric_value.items():
      logger.info('  Timestamp: {0:s}, value: {1:s}'.format(timestamp, value))
Query Azure Monitoring metrics for a resource.

Args:
args (argparse.Namespace): Arguments from ArgumentParser.

Raises:
RuntimeError: If from_date or to_date could not be parsed.
tools/az_cli.py