public async static Task Run([TimerTrigger("0 0 * * * *")] TimerInfo myTimer, TraceWriter log, ExecutionContext context) { var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); string eventHubName = config["EventHubName"]; string eventHubConnectionString = config["EventHubConnectionString"]; var container = new CustomerContainer() { Currency = config["Currency"], RegionInfo = config["RegionInfo"], SubscriptionId = config["SubscriptionId"], ClientId = config["client_Id"], ClientKey = config["client_key"], TenantDomain = config["tenant"], OfferId = config["OfferId"], ArmBillingServiceUrl = config["ARMBillingServiceURL"], AdalServiceUrl = config["ADALServiceURL"] }; var invoker = new BillingInvoker(eventHubName, eventHubConnectionString); await invoker.PopulateRecentRateAndUsageInformation(container); }
static async Task Main(string[] args) { var container = BillingInvoker.GetCustomerContainer(); if (container.EventHubEntity == "billingdemo") { Console.WriteLine("Starting billing extraction"); await GetLastHourBilling(); Console.WriteLine("Ending billing extraction"); } else { Console.WriteLine("Starting metrics extraction"); var metrics = await GetMetrics(); Console.WriteLine("Ending metrics extraction"); } Console.WriteLine("Press any key ..."); Console.Read(); }
public static async Task <List <DatabaseMetric> > GetMetrics() { var metrics = new DatabaseMetrics(); return(await metrics.GetMetrics(BillingInvoker.GetCustomerContainer())); }
public static async Task GetLastHourBilling() { var invoker = new BillingInvoker(); await invoker.PopulateRecentRateAndUsageInformation(BillingInvoker.GetCustomerContainer()); }