Example #1
0
        public static async Task Run([TimerTrigger("%DEVICE_LIFECYCLE_IMPORT_TIMER%")] TimerInfo timer, TraceWriter log)
        {
            log.Info($"Import started at {DateTime.Now}");
            long importedItemCount = 0;

            try
            {
                importedItemCount = await IotHubClient.ImportDevice(log);
            }
            catch (HttpRequestException httpRequestEx)
            {
            }

            log.Info($"Imported {importedItemCount} new devices to Azure Iot Hub at {DateTime.Now}");
        }
Example #2
0
        public static async Task <object> Run([HttpTrigger] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("Import started from http trigger");
            long importedItemCount = 0;

            try
            {
                importedItemCount = await IotHubClient.ImportDevice(log);
            }
            catch (HttpRequestException httpRequestEx)
            {
                return(req.CreateResponse(HttpStatusCode.InternalServerError, new
                {
                    error = "Internal Server Error"
                }));
            }

            return(req.CreateResponse(HttpStatusCode.OK, new
            {
                message = $"Imported {importedItemCount} new devices to Azure Iot Hub"
            }));
        }