Exemplo n.º 1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] ODWorkspaceOwner owner,
            ILogger log)
        {
            log.LogInformation("HTTP triggered (SaveODWorkspace) function");

            var workspaceManager = await ODWorkspaceManagerHelper.SetWorkspaceManager(owner.OwnerId, owner.CreateIfNotExists);

            var workspace = await workspaceManager.GetWorkspaceAsync(owner.OwnerId, true);

            try
            {
                //Upload data to custom vision adhoc project
                await workspaceManager.PrepareWorkspaceForTraining();

                //create new training iteration, generate the offline models and upload them to storage
                await workspaceManager.TrainPreparedWorkspace();

                return(new OkObjectResult("Training completed successfully"));
            }
            catch (Exception ex)
            {
                log.LogError($"FAILED: {ex.Message}");
                return(new BadRequestObjectResult($"Addition of the file failed"));
            }
        }
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] ODWorkspaceOwner owner,
            ILogger log)
        {
            log.LogInformation("HTTP triggered (GetOrCreateODWorkspace) function");

            try
            {
                var workspaceManager = await ODWorkspaceManagerHelper.SetWorkspaceManager(owner.OwnerId, owner.CreateIfNotExists);

                ODMWorkspace workspace;

                if (owner != null)
                    workspace = await workspaceManager.GetWorkspaceAsync(owner.OwnerId, true);
                else
                    return new BadRequestObjectResult("Owner was not found. You should submit owner in the request body");

                if (workspace != null)
                    return new OkObjectResult(workspace);
                else
                    return new BadRequestObjectResult("Workspace could not be found or created");
            }
            catch (Exception ex)
            {
                log.LogError($"FAILED: {ex.Message}");
                return new BadRequestObjectResult("Workspace could not be found or created");
            }
        }