/// <inheritdoc/>
        protected override void ProcessRecordInternal()
        {
            BackupStorageDescription backupStorageDescription = null;

            if (this.AzureBlobStore.IsPresent)
            {
                backupStorageDescription = new AzureBlobBackupStorageDescription(
                    connectionString: this.ConnectionString,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }
            else if (this.FileShare.IsPresent)
            {
                backupStorageDescription = new FileShareBackupStorageDescription(
                    path: this.Path,
                    friendlyName: this.FriendlyName,
                    primaryUserName: this.PrimaryUserName,
                    primaryPassword: this.PrimaryPassword,
                    secondaryUserName: this.SecondaryUserName,
                    secondaryPassword: this.SecondaryPassword);
            }
            else if (this.DsmsAzureBlobStore.IsPresent)
            {
                backupStorageDescription = new DsmsAzureBlobBackupStorageDescription(
                    storageCredentialsSourceLocation: this.StorageCredentialsSourceLocation,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }
            else if (this.ManagedIdentityAzureBlobStore.IsPresent)
            {
                backupStorageDescription = new ManagedIdentityAzureBlobBackupStorageDescription(
                    managedIdentityType: this.ManagedIdentityType,
                    blobServiceUri: this.BlobServiceUri,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }

            var restorePartitionDescription = new RestorePartitionDescription(
                backupId: this.BackupId,
                backupLocation: this.BackupLocation,
                backupStorage: backupStorageDescription);

            this.ServiceFabricClient.BackupRestore.RestorePartitionAsync(
                partitionId: this.PartitionId,
                restorePartitionDescription: restorePartitionDescription,
                restoreTimeout: this.RestoreTimeout,
                serverTimeout: this.ServerTimeout,
                cancellationToken: this.CancellationToken).GetAwaiter().GetResult();

            Console.WriteLine("Success!");
        }
        /// <summary>
        /// Serializes the object to JSON.
        /// </summary>
        /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="obj">The object to serialize to JSON.</param>
        internal static void Serialize(JsonWriter writer, DsmsAzureBlobBackupStorageDescription obj)
        {
            // Required properties are always serialized, optional properties are serialized when not null.
            writer.WriteStartObject();
            writer.WriteProperty(obj.StorageKind, "StorageKind", BackupStorageKindConverter.Serialize);
            writer.WriteProperty(obj.StorageCredentialsSourceLocation, "StorageCredentialsSourceLocation", JsonWriterExtensions.WriteStringValue);
            writer.WriteProperty(obj.ContainerName, "ContainerName", JsonWriterExtensions.WriteStringValue);
            if (obj.FriendlyName != null)
            {
                writer.WriteProperty(obj.FriendlyName, "FriendlyName", JsonWriterExtensions.WriteStringValue);
            }

            writer.WriteEndObject();
        }
        /// <inheritdoc/>
        protected override void ProcessRecordInternal()
        {
            BackupScheduleDescription backupScheduleDescription = null;

            if (this.FrequencyBased.IsPresent)
            {
                backupScheduleDescription = new FrequencyBasedBackupScheduleDescription(
                    interval: this.Interval);
            }
            else if (this.TimeBased.IsPresent)
            {
                backupScheduleDescription = new TimeBasedBackupScheduleDescription(
                    scheduleFrequencyType: this.ScheduleFrequencyType,
                    runTimes: this.RunTimes,
                    runDays: this.RunDays);
            }

            BackupStorageDescription backupStorageDescription = null;

            if (this.AzureBlobStore.IsPresent)
            {
                backupStorageDescription = new AzureBlobBackupStorageDescription(
                    connectionString: this.ConnectionString,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }
            else if (this.FileShare.IsPresent)
            {
                backupStorageDescription = new FileShareBackupStorageDescription(
                    path: this.Path,
                    friendlyName: this.FriendlyName,
                    primaryUserName: this.PrimaryUserName,
                    primaryPassword: this.PrimaryPassword,
                    secondaryUserName: this.SecondaryUserName,
                    secondaryPassword: this.SecondaryPassword);
            }
            else if (this.DsmsAzureBlobStore.IsPresent)
            {
                backupStorageDescription = new DsmsAzureBlobBackupStorageDescription(
                    storageCredentialsSourceLocation: this.StorageCredentialsSourceLocation,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }

            RetentionPolicyDescription retentionPolicyDescription = null;

            if (this.Basic.IsPresent)
            {
                retentionPolicyDescription = new BasicRetentionPolicyDescription(
                    retentionDuration: this.RetentionDuration,
                    minimumNumberOfBackups: this.MinimumNumberOfBackups);
            }

            var backupPolicyDescription = new BackupPolicyDescription(
                name: this.Name,
                autoRestoreOnDataLoss: this.AutoRestoreOnDataLoss,
                maxIncrementalBackups: this.MaxIncrementalBackups,
                schedule: backupScheduleDescription,
                storage: backupStorageDescription,
                retentionPolicy: retentionPolicyDescription);

            this.ServiceFabricClient.BackupRestore.CreateBackupPolicyAsync(
                backupPolicyDescription: backupPolicyDescription,
                serverTimeout: this.ServerTimeout,
                cancellationToken: this.CancellationToken).GetAwaiter().GetResult();

            Console.WriteLine("Success!");
        }
        /// <inheritdoc/>
        protected override void ProcessRecordInternal()
        {
            BackupStorageDescription backupStorageDescription = null;

            if (this.AzureBlobStore.IsPresent)
            {
                backupStorageDescription = new AzureBlobBackupStorageDescription(
                    connectionString: this.ConnectionString,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }
            else if (this.FileShare.IsPresent)
            {
                backupStorageDescription = new FileShareBackupStorageDescription(
                    path: this.Path,
                    friendlyName: this.FriendlyName,
                    primaryUserName: this.PrimaryUserName,
                    primaryPassword: this.PrimaryPassword,
                    secondaryUserName: this.SecondaryUserName,
                    secondaryPassword: this.SecondaryPassword);
            }
            else if (this.DsmsAzureBlobStore.IsPresent)
            {
                backupStorageDescription = new DsmsAzureBlobBackupStorageDescription(
                    storageCredentialsSourceLocation: this.StorageCredentialsSourceLocation,
                    containerName: this.ContainerName,
                    friendlyName: this.FriendlyName);
            }

            BackupEntity backupEntity = null;

            if (this.Application.IsPresent)
            {
                backupEntity = new ApplicationBackupEntity(
                    applicationName: this.ApplicationName);
            }
            else if (this.Service.IsPresent)
            {
                backupEntity = new ServiceBackupEntity(
                    serviceName: this.ServiceName);
            }
            else if (this.Partition.IsPresent)
            {
                backupEntity = new PartitionBackupEntity(
                    serviceName: this.ServiceName,
                    partitionId: this.PartitionId);
            }

            var getBackupByStorageQueryDescription = new GetBackupByStorageQueryDescription(
                storage: backupStorageDescription,
                backupEntity: backupEntity,
                startDateTimeFilter: this.StartDateTimeFilter,
                endDateTimeFilter: this.EndDateTimeFilter,
                latest: this.Latest);

            var continuationToken = default(ContinuationToken);

            do
            {
                var result = this.ServiceFabricClient.BackupRestore.GetBackupsFromBackupLocationAsync(
                    getBackupByStorageQueryDescription: getBackupByStorageQueryDescription,
                    serverTimeout: this.ServerTimeout,
                    continuationToken: continuationToken,
                    maxResults: this.MaxResults,
                    cancellationToken: this.CancellationToken).GetAwaiter().GetResult();

                if (result == null)
                {
                    break;
                }

                var count = 0;
                foreach (var item in result.Data)
                {
                    count++;
                    this.WriteObject(this.FormatOutput(item));
                }

                continuationToken = result.ContinuationToken;
                this.WriteDebug(string.Format(Resource.MsgCountAndContinuationToken, count, continuationToken));
            }while (continuationToken.Next);
        }