public override void ExecuteCmdlet()
 {
     base.ExecuteCmdlet();
     var freq = BackupRestoreUtils.StringToFrequencyUnit(FrequencyUnit);
     BackupSchedule schedule = new BackupSchedule(freq, FrequencyInterval, KeepAtLeastOneBackup.IsPresent,
         RetentionPeriodInDays, StartTime);
     BackupRequest request = new BackupRequest()
     {
         Location = "",
         Enabled = true,
         StorageAccountUrl = this.StorageAccountUrl,
         BackupSchedule = schedule,
         Databases = this.Databases,
         BackupRequestType = BackupRestoreOperationType.Default
     };
     WebsitesClient.UpdateWebAppBackupConfiguration(ResourceGroupName, Name, Slot, request);
     var config = new AzureWebAppBackupConfiguration()
     {
         Name = this.Name,
         ResourceGroupName = this.ResourceGroupName,
         StorageAccountUrl = this.StorageAccountUrl,
         FrequencyInterval = this.FrequencyInterval,
         FrequencyUnit = this.FrequencyUnit,
         RetentionPeriodInDays = this.RetentionPeriodInDays,
         StartTime = this.StartTime,
         KeepAtLeastOneBackup = this.KeepAtLeastOneBackup.IsPresent,
         Databases = this.Databases,
         Enabled = true
     };
     WriteObject(config);
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the BackupRequest class.
 /// </summary>
 public BackupRequest(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), string backupRequestName = default(string), bool?enabled = default(bool?), string storageAccountUrl = default(string), BackupSchedule backupSchedule = default(BackupSchedule), IList <DatabaseBackupSetting> databases = default(IList <DatabaseBackupSetting>), BackupRestoreOperationType?backupRequestType = default(BackupRestoreOperationType?))
     : base(location, id, name, type, tags)
 {
     BackupRequestName = backupRequestName;
     Enabled           = enabled;
     StorageAccountUrl = storageAccountUrl;
     BackupSchedule    = backupSchedule;
     Databases         = databases;
     BackupRequestType = backupRequestType;
 }
 /// <summary>
 /// Initializes a new instance of the BackupRequest class.
 /// </summary>
 /// <param name="storageAccountUrl">SAS URL to the container.</param>
 /// <param name="id">Resource Id.</param>
 /// <param name="name">Resource Name.</param>
 /// <param name="kind">Kind of resource.</param>
 /// <param name="type">Resource type.</param>
 /// <param name="backupName">Name of the backup.</param>
 /// <param name="enabled">True if the backup schedule is enabled (must
 /// be included in that case), false if the backup schedule should be
 /// disabled.</param>
 /// <param name="backupSchedule">Schedule for the backup if it is
 /// executed periodically.</param>
 /// <param name="databases">Databases included in the backup.</param>
 public BackupRequest(string storageAccountUrl, string id = default(string), string name = default(string), string kind = default(string), string type = default(string), string backupName = default(string), bool?enabled = default(bool?), BackupSchedule backupSchedule = default(BackupSchedule), IList <DatabaseBackupSetting> databases = default(IList <DatabaseBackupSetting>))
     : base(id, name, kind, type)
 {
     BackupName        = backupName;
     Enabled           = enabled;
     StorageAccountUrl = storageAccountUrl;
     BackupSchedule    = backupSchedule;
     Databases         = databases;
     CustomInit();
 }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (StorageAccountUrl == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "StorageAccountUrl");
     }
     if (BackupSchedule != null)
     {
         BackupSchedule.Validate();
     }
     if (Databases != null)
     {
         foreach (var element in Databases)
         {
             if (element != null)
             {
                 element.Validate();
             }
         }
     }
 }