public static async Task <IActionResult> HttpTrigger(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpTriggerArgs args,
            [OrchestrationClient] IDurableOrchestrationClient durableOrchestrationClient,
            ILogger log)
        {
            // 'orchestrationId = DeviceId' > tricky stuff, make sure the orchestrationId is deterministic but also unique and has now weird characters
            var orchestrationId = args.DeviceId;
            var status          = await durableOrchestrationClient.GetStatusAsync(orchestrationId);

            // Maybe do this from within the Orchestrator
            var entity = new EntityId(nameof(DeviceEntity), args.DeviceId);
            await durableOrchestrationClient.SignalEntityAsync(entity, "UpdateLastCommunicationDateTime");

            switch (status?.RuntimeStatus)
            {
            case OrchestrationRuntimeStatus.Running:
            case OrchestrationRuntimeStatus.Pending:
            case OrchestrationRuntimeStatus.ContinuedAsNew:
                await durableOrchestrationClient.RaiseEventAsync(orchestrationId, "MessageReceived", null);

                break;

            default:
                await durableOrchestrationClient.StartNewAsync(nameof(WaitingOrchestrator), orchestrationId, new OrchestratorArgs { DeviceId = args.DeviceId });

                break;
            }

            log.LogInformation("Started orchestration with ID = '{orchestrationId}'.", orchestrationId);
            var response = durableOrchestrationClient.CreateHttpManagementPayload(orchestrationId);

            return(new OkObjectResult(response));
        }
        public static async Task <IActionResult> GetStatus(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpTriggerArgs args,
            [DurableClient] IDurableEntityClient durableEntityClient)
        {
            var entity = new EntityId(nameof(DeviceEntity), args.DeviceId);
            var device = await durableEntityClient.ReadEntityStateAsync <DeviceEntity>(entity);

            return(new OkObjectResult(device));
        }