internal override async Task <BackupProgress> RunAsync(TimeSpan timeout, CancellationToken cancellationToken)
        {
            string fabricUri = await UtilityHelper.GetFabricUriFromRequstHeaderForPartitions(this.fabricRequestHeader, timeout, cancellationToken);

            BackupPartitionStatus backupPartitionStatus = await this.BackupPartitionStore.GetValueAsync(fabricUri, timeout, cancellationToken);

            if (backupPartitionStatus == null)
            {
                return(null);
            }
            return(backupPartitionStatus.ToBackupPartitionResponse());
        }
        internal override async Task <HttpResponseMessage> RunAsync(TimeSpan timeout, CancellationToken cancellationToken)
        {
            string applicationNameUri;
            string serviceNameUri;
            string partitionId;
            string fabricUri = await UtilityHelper.GetFabricUriFromRequstHeaderForPartitions(this.fabricRequestHeader, timeout, cancellationToken);

            UtilityHelper.GetApplicationAndServicePartitionUri(fabricUri, out applicationNameUri, out serviceNameUri, out partitionId);
            BackupStorage backupStorageModel;

            if (this.backupStorage == null)
            {
                var backupMapping = (await this.BackupMappingStore.GetValueAsync(fabricUri) ??
                                     await this.BackupMappingStore.GetValueAsync(serviceNameUri)) ??
                                    await this.BackupMappingStore.GetValueAsync(UtilityHelper.GetApplicationNameFromService(applicationNameUri));

                if (backupMapping == null)
                {
                    throw new FabricPeriodicBackupNotEnabledException();
                }

                var backupPolicy = await this.BackupPolicyStore.GetValueAsync(backupMapping.BackupPolicyName, timeout, cancellationToken);

                backupStorageModel = backupPolicy.Storage;
            }
            else
            {
                backupStorageModel = BackupStorage.FromBackupStorageView(this.backupStorage);
            }

            var backupRequestGuid     = Guid.NewGuid();
            var backupPartitionStatus = new BackupPartitionStatus(fabricUri, backupRequestGuid);
            var sendBackupPartitionToServiceNodeWorkItem = new BackupPartitionWorkItem(serviceNameUri, partitionId, backupStorageModel, backupRequestGuid, this.backupTimeoutinMinutes);

            using (var transaction = this.StatefulService.StateManager.CreateTransaction())
            {
                await this.CheckForEitherBackupOrRestoreInProgress(fabricUri, timeout, cancellationToken, transaction);

                await this.WorkItemQueue.AddWorkItem(sendBackupPartitionToServiceNodeWorkItem, timeout, cancellationToken, transaction);

                await this.BackupPartitionStore.AddOrUpdateAsync(fabricUri, backupPartitionStatus, (fabricUriKey, backupPartitionStatusUpdate) => backupPartitionStatus, timeout, cancellationToken, transaction);

                await transaction.CommitAsync();
            }
            return(new HttpResponseMessage(HttpStatusCode.Accepted));
        }