public static async Task <IActionResult> excecute(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");
            //get data from
            string storageAccount   = req.Headers["StorageAccount"];
            string rootFolder       = req.Headers["RootFolder"];
            string localFolder      = req.Headers["LocalFolder"];
            string resolveReference = req.Headers["ResolveReference"];

            string     requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            EntityList entityList  = JsonConvert.DeserializeObject <EntityList>(requestBody);

            var         TenantId    = System.Environment.GetEnvironmentVariable("TenantId");
            var         AppId       = System.Environment.GetEnvironmentVariable("AppId");;
            var         AppSecret   = System.Environment.GetEnvironmentVariable("AppSecret");
            AdlsContext adlsContext = new AdlsContext()
            {
                StorageAccount = storageAccount,
                FileSytemName  = rootFolder,
                TenantId       = TenantId,
                ClientAppId    = AppId,
                ClientSecret   = AppSecret
            };
            ManifestHandler manifestHandler = new ManifestHandler(adlsContext, localFolder);

            bool resolveRef = false;

            if (resolveReference.Equals("true", StringComparison.OrdinalIgnoreCase))
            {
                resolveRef = true;
            }

            bool ManifestCreated = await manifestHandler.createManifest(entityList, resolveRef);

            //Folder structure Tables/AccountReceivable/Group
            var    subFolders      = localFolder.Split('/');
            string localFolderPath = "";

            for (int i = 0; i < subFolders.Length - 1; i++)
            {
                var currentFolder = subFolders[i];
                var nextFolder    = subFolders[i + 1];
                localFolderPath = $"{localFolderPath}/{currentFolder}";

                ManifestHandler SubManifestHandler = new ManifestHandler(adlsContext, localFolderPath);
                await SubManifestHandler.createSubManifest(currentFolder, nextFolder);
            }

            var status = new ManifestStatus()
            {
                ManifestName = entityList.manifestName, IsManifestCreated = ManifestCreated
            };

            return(new OkObjectResult(JsonConvert.SerializeObject(status)));
        }
        private bool IcsGetNewOperations(MailboxSyncWatermark minWatermark, bool enumerateDeletes, int numOperations, Dictionary <ISyncItemId, ServerManifestEntry> newServerManifest)
        {
            this.SyncLogger.Information <int, int>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.IcsGetNewOperations.  NumOperations {0}, newServerManifest.Count {1}", numOperations, newServerManifest.Count);
            bool         flag         = false;
            MemoryStream memoryStream = null;

            try
            {
                StoreSession session = this.folder.Session;
                bool         flag2   = false;
                try
                {
                    if (session != null)
                    {
                        session.BeginMapiCall();
                        session.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    try
                    {
                        flag = this.EnsureMapiManifest(minWatermark, numOperations, newServerManifest);
                        if (flag)
                        {
                            this.SyncLogger.Information(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.IcsGetNewOperations.  EnsureMapiManifest returned true (moreAvailable).  Bailing out.");
                            return(flag);
                        }
                        memoryStream = new MemoryStream();
                        ManifestStatus manifestStatus = ManifestStatus.Yielded;
                        while (manifestStatus == ManifestStatus.Yielded)
                        {
                            manifestStatus = this.manifest.Synchronize();
                            switch (manifestStatus)
                            {
                            case ManifestStatus.Done:
                            case ManifestStatus.Yielded:
                                this.manifest.GetState(memoryStream);
                                minWatermark.IcsState = memoryStream.ToArray();
                                this.icsState         = minWatermark.IcsState;
                                break;

                            case ManifestStatus.Stopped:
                                this.extraServerManifestEntry = this.icsCallback.ExtraServerManiferEntry;
                                this.SyncLogger.Information <string>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider::IcsGetNewOperations Got additional change, id = {0}", (this.extraServerManifestEntry == null) ? "NULL" : this.extraServerManifestEntry.Id.ToString());
                                break;
                            }
                        }
                        flag = this.icsCallback.MoreAvailable;
                        this.SyncLogger.Information <bool>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "MailboxSyncProvider.IcsGetNewOperations.  More available after ICS sync? {0}", flag);
                    }
                    catch (MapiExceptionCorruptData innerException)
                    {
                        throw new CorruptSyncStateException(ServerStrings.ExSyncStateCorrupted("ICS"), innerException);
                    }
                    catch (CorruptDataException innerException2)
                    {
                        throw new CorruptSyncStateException(ServerStrings.ExSyncStateCorrupted("ICS"), innerException2);
                    }
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ICSSynchronizationFailed, ex, session, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MailboxSyncProvider::IcsGetNewOperations()", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ICSSynchronizationFailed, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MailboxSyncProvider::IcsGetNewOperations()", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (session != null)
                        {
                            session.EndMapiCall();
                            if (flag2)
                            {
                                session.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
            }
            finally
            {
                Util.DisposeIfPresent(memoryStream);
            }
            return(flag);
        }