示例#1
0
        public static async Task MetricCollector(
            [TimerTrigger("0 */1 * * * *")] TimerInfo myTimer,
            [OrchestrationClient] DurableOrchestrationClient client,
            TraceWriter log)
        {
            log.Info($"MetricCollector function executed at: {DateTime.Now}");
            var resource = Environment.GetEnvironmentVariable("ResourceToScale");

            //await client.TerminateAsync(resource, "");
            var status = await client.GetStatusAsync(resource);

            if (status == null)
            {
                await client.StartNewAsync(nameof(ScalingLogic), resource, new ScalingState());
            }
            else
            {
                var metric = ServiceBusHelper.GetSubscriptionMetric(resource);
                log.Info($"Collector: Current metric value is {metric.Value.Value} at {DateTime.Now}");
                await client.RaiseEventAsync(resource, nameof(Metric), metric);
            }
        }