/// <summary>
        /// Creates and returns <see cref="AutoBackupSettings"/> object.
        /// </summary>
        protected override void ProcessRecord()
        {
            AutoBackupSettings autoBackupSettings = new AutoBackupSettings();

            autoBackupSettings.Enable           = (Enable.IsPresent) ? Enable.ToBool() : false;
            autoBackupSettings.EnableEncryption = (EnableEncryption.IsPresent) ? EnableEncryption.ToBool() : false;
            autoBackupSettings.RetentionPeriod  = RetentionPeriodInDays;

            switch (ParameterSetName)
            {
            case StorageContextParamSetName:
                autoBackupSettings.StorageUrl       = StorageContext.BlobEndPoint;
                autoBackupSettings.StorageAccessKey = this.GetStorageKey();
                break;

            case StorageUriParamSetName:
                autoBackupSettings.StorageUrl       = (StorageUri == null)? null: StorageUri.ToString();
                autoBackupSettings.StorageAccessKey = (StorageKey == null)? null: SecureStringHelper.ConvertToUnsecureString(StorageKey);
                break;
            }

            // Check if certificate password was set
            autoBackupSettings.Password = (CertificatePassword == null) ? null : SecureStringHelper.ConvertToUnsecureString(CertificatePassword);

            WriteObject(autoBackupSettings);
        }
        /// <summary>
        /// Creates and returns <see cref="PublicKeyVaultCredentialSettings"/> object.
        /// </summary>
        protected override void ProcessRecord()
        {
            KeyVaultCredentialSettings settings = new KeyVaultCredentialSettings();

            settings.Enable = (this.Enable.IsPresent) ? this.Enable.ToBool() : false;

            settings.CredentialName = (this.CredentialName == null) ? null : this.CredentialName;

            settings.ServicePrincipalName = (this.ServicePrincipalName == null) ? null : this.ServicePrincipalName;

            settings.ServicePrincipalSecret = (this.ServicePrincipalSecret == null) ?
                                              null :
                                              SecureStringHelper.ConvertToUnsecureString(this.ServicePrincipalSecret);

            settings.AzureKeyVaultUrl = (this.AzureKeyVaultUrl == null) ? null : this.AzureKeyVaultUrl;


            WriteObject(settings);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates and returns <see cref="AutoBackupSettings"/> object.
        /// </summary>
        protected override void ProcessRecord()
        {
            AutoBackupSettings autoBackupSettings = new AutoBackupSettings();

            autoBackupSettings.Enable           = (Enable.IsPresent) ? Enable.ToBool() : false;
            autoBackupSettings.EnableEncryption = (EnableEncryption.IsPresent) ? EnableEncryption.ToBool() : false;
            autoBackupSettings.RetentionPeriod  = RetentionPeriodInDays;

            switch (ParameterSetName)
            {
            case StorageContextParamSetName:
                autoBackupSettings.StorageUrl       = StorageContext.BlobEndPoint;
                autoBackupSettings.StorageAccessKey = this.GetStorageKey();
                break;

            case StorageUriParamSetName:
                autoBackupSettings.StorageUrl       = (StorageUri == null)? null: StorageUri.ToString();
                autoBackupSettings.StorageAccessKey = (StorageKey == null)? null: SecureStringHelper.ConvertToUnsecureString(StorageKey);
                break;
            }

            // Check if certificate password was set
            autoBackupSettings.Password = (CertificatePassword == null) ? null : SecureStringHelper.ConvertToUnsecureString(CertificatePassword);

            autoBackupSettings.BackupSystemDbs    = BackupSystemDbs.IsPresent ? BackupSystemDbs.ToBool() : false;
            autoBackupSettings.BackupScheduleType = BackupScheduleType;

            // Set other Backup schedule settings only if BackUpSchedule type is Manual.
            if (!string.IsNullOrEmpty(BackupScheduleType) && string.Equals(BackupScheduleType, BackupScheduleManualType, StringComparison.InvariantCultureIgnoreCase))
            {
                ValidateBackupScheduleSettings();

                autoBackupSettings.FullBackupFrequency   = FullBackupFrequency;
                autoBackupSettings.FullBackupStartTime   = FullBackupStartHour;
                autoBackupSettings.FullBackupWindowHours = FullBackupWindowInHours;
                autoBackupSettings.LogBackupFrequency    = LogBackupFrequencyInMinutes;
            }

            WriteObject(autoBackupSettings);
        }