async def check_last_failed_status_and_start_execution(self, index, end_epoch):
        """Check if last invocation was interrupted or not and start the execution accordingly.

        Args:
            index (int): index of iterator
            end_epoch (int): end epoch time
        """
        __method_name = inspect.currentframe().f_code.co_name
        try:
            async with aiohttp.ClientSession(
                headers={
                    "User-Agent": "Netskope MSSentinel",
                    "Netskope-Api-Token": consts.NETSKOPE_TOKEN,
                }
            ) as session:
                is_last_failed_obj = StateManager(
                    consts.CONNECTION_STRING,
                    "{}_is_last_failed".format(index),
                    self.share_name,
                )
                while True:
                    # DATA_COLLECTION_TIMEOUT value is 570 seconds which is 9 minutes and 30 seconds
                    # We stop the exection at 9 minutes and 30 seconds to avoid issues due to function timeout.
                    if int(time.time()) >= self.starttime + consts.DATA_COLLECTION_TIMEOUT:
                        applogger.info(
                            "{}(method={}) : {} ({}) : 9:30 mins executed hence breaking.".format(
                                consts.LOGS_STARTS_WITH,
                                __method_name,
                                consts.NETSKOPE_TO_AZURE_STORAGE,
                                self.nskp_data_type_for_logging,
                            )
                        )
                        break
                    is_last_failed = is_last_failed_obj.get(consts.NETSKOPE_TO_AZURE_STORAGE)
                    if is_last_failed == "False":
                        applogger.debug(
                            "{}(method={}) : {} ({}) : Fetching next Netskope data for iterator {}.".format(
                                consts.LOGS_STARTS_WITH,
                                __method_name,
                                consts.NETSKOPE_TO_AZURE_STORAGE,
                                self.nskp_data_type_for_logging,
                                index,
                            )
                        )
                        is_last_failed_obj.post("True")
                        url = self.netskope_api_async_obj.url_builder(index, "next")
                        end_epoch_to_update = await self.get_netskope_data_and_post_to_azure_storage(
                            index, url, session, end_epoch
                        )
                        is_last_failed_obj.post("False")
                    else:
                        applogger.debug(
                            "{}(method={}) : {} ({}) : Last iteration failed for iterator {}, hence retrying.".format(
                                consts.LOGS_STARTS_WITH,
                                __method_name,
                                consts.NETSKOPE_TO_AZURE_STORAGE,
                                self.nskp_data_type_for_logging,
                                index,
                            )
                        )
                        url = self.netskope_api_async_obj.url_builder(index, "resend")
                        end_epoch_to_update = await self.get_netskope_data_and_post_to_azure_storage(
                            index, url, session, end_epoch, True
                        )
                        is_last_failed_obj.post("False")
                    self.count += 1
                    applogger.debug(
                        "{}(method={}) : {} ({}) : The number of files stored to azure storage is {}.".format(
                            consts.LOGS_STARTS_WITH,
                            __method_name,
                            consts.NETSKOPE_TO_AZURE_STORAGE,
                            self.nskp_data_type_for_logging,
                            self.count,
                        )
                    )
                    if end_epoch_to_update is not None:
                        end_epoch = end_epoch_to_update
        except NetskopeException:
            applogger.error(
                "{}(method={}) : {} ({}) : Error while getting Netskope data.".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.NETSKOPE_TO_AZURE_STORAGE,
                    self.nskp_data_type_for_logging,
                )
            )
            raise NetskopeException()
        except Exception as error:
            applogger.error(
                "{}(method={}) : {} ({}) : Error captured in get data, Error-{}.".format(
                    consts.LOGS_STARTS_WITH,
                    __method_name,
                    consts.NETSKOPE_TO_AZURE_STORAGE,
                    self.nskp_data_type_for_logging,
                    error,
                )
            )
            raise NetskopeException()
Check if last invocation was interrupted or not and start the execution accordingly.

        Args:
            index (int): index of iterator
            end_epoch (int): end epoch time
        
Solutions/Netskopev2/Data Connectors/NetskopeDataConnector/NetskopeToAzureStorage/netskope_to_azure_storage.py