public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log,
            ExecutionContext context)
        {
            log.LogInformation($"{nameof(StartVm)} function processed a request.");

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            string[] values       = requestBody.Split('=');
            string   vmName       = null;
            string   startMessage = "";

            if (values[0] == "vmname")
            {
                vmName = values[1];
                FunctionHelpers helper    = new FunctionHelpers(nameof(GetVms), log, context);
                AzureVmManager  vmManager = AzureVmManager.CreateVmManagerInstance(helper);
                startMessage = await vmManager.StartVirtualMachineAsync(vmName);
            }

            VmHtmlMaker htmlMaker = new VmHtmlMaker(context.FunctionAppDirectory, req);
            string      html      = htmlMaker.GetStateChangedPage(startMessage);

            return
                (new ContentResult
            {
                Content = html,
                ContentType = "text/html"
            });
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log,
            ExecutionContext context)
        {
            FunctionHelpers helper    = new FunctionHelpers(nameof(GetVms), log, context);
            AzureVmManager  vmManager = AzureVmManager.CreateVmManagerInstance(helper);
            IPagedCollection <IVirtualMachine> machines = await vmManager.GetVirtualMachinesAsync();


            VmHtmlMaker vmHtmlMaker = new VmHtmlMaker(context.FunctionAppDirectory, req);
            string      html        = vmHtmlMaker.GetHtml(machines);

            var result = new ContentResult
            {
                Content     = html,
                ContentType = "text/html"
            };

            return(result);
        }
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log,
            ExecutionContext context)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            string[] values  = requestBody.Split('=');
            string   vmName  = null;
            bool     success = false;
            string   message;

            if (values[0] == "vmname")
            {
                vmName = values[1];
                FunctionHelpers helper    = new FunctionHelpers(nameof(GetVms), log, context);
                AzureVmManager  vmManager = AzureVmManager.CreateVmManagerInstance(helper);
                success = await vmManager.DeallocateVmAsync(vmName);

                message = $"{vmName} is deallocating";
            }
            else
            {
                message = "submit expected form";
            }

            VmHtmlMaker htmlMaker = new VmHtmlMaker(context.FunctionAppDirectory, req);
            string      html      = htmlMaker.GetStateChangedPage(message);


            return
                (new ContentResult
            {
                Content = html,
                ContentType = "text/html"
            });
        }