Skip to content

Commit 4032ca8

Browse files
author
Anil Kumar Yelam
committed
Added new params for AutoBackup, Tests exlcluded.
1 parent a3dff10 commit 4032ca8

7 files changed

+26238
-572
lines changed

src/ResourceManager/Compute/AzureRM.Compute.psd1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ CmdletsToExport = 'Remove-AzureRmAvailabilitySet', 'Get-AzureRmAvailabilitySet',
8989
'Set-AzureRmVMDiagnosticsExtension', 'Set-AzureRmVMExtension',
9090
'Remove-AzureRmVMExtension', 'Get-AzureRmVMExtension',
9191
'Get-AzureRmVMSqlServerExtension',
92-
'New-AzureVMSqlServerAutoBackupConfig',
93-
'New-AzureVMSqlServerAutoPatchingConfig',
94-
'New-AzureVMSqlServerKeyVaultCredentialConfig',
92+
'New-AzureRmVMSqlServerAutoBackupConfig',
93+
'New-AzureRmVMSqlServerAutoPatchingConfig',
94+
'New-AzureRmVMSqlServerKeyVaultCredentialConfig',
9595
'Remove-AzureRmVMSqlServerExtension',
9696
'Set-AzureRmVMSqlServerExtension', 'Get-AzureRmVMImage',
9797
'Get-AzureRmVMAccessExtension', 'Remove-AzureRmVMAccessExtension',

src/ResourceManager/Compute/Commands.Compute/Common/ConstantStringTypes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public static class ProfileNouns
126126

127127
// Sql Server
128128
public const string VirtualMachineSqlServerExtension = "AzureRmVMSqlServerExtension";
129+
public const string VirtualMachineSqlServerAutoBackupConfig = "AzureRmVMSqlServerAutoBackupConfig";
130+
public const string VirtualMachineSqlServerAutoPatchingConfig = "AzureRmVMSqlServerAutoPatchingConfig";
131+
public const string VirtualMachineSqlServerKeyVaultCredentialConfig = "AzureVMSqlServerKeyVaultCredentialConfig";
129132

130133
//AzureDiskEncryption
131134
public const string AzureDiskEncryptionExtension = "AzureRmVMDiskEncryptionExtension";

src/ResourceManager/Compute/Commands.Compute/Extension/SqlServer/AzureVMSqlServerAutoBackupSettings.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,35 @@ public class AutoBackupSettings
5252
/// </summary>
5353
[JsonIgnoreAttribute()]
5454
public string Password { get; set; }
55+
56+
/// <summary>
57+
/// Whether to include system databases in Backup
58+
/// </summary>
59+
public bool? BackupSystemDbs { get; set; }
60+
61+
/// <summary>
62+
/// Gets the Backup Schedule Type
63+
/// </summary>
64+
public string BackupScheduleType { get; set; }
65+
66+
/// <summary>
67+
/// Gets the Full Backup Frequency
68+
/// </summary>
69+
public string FullBackupFrequency { get; set; }
70+
71+
/// <summary>
72+
/// Gets the Full Backup Start Time
73+
/// </summary>
74+
public int? FullBackupStartTime { get; set; }
75+
76+
/// <summary>
77+
/// Gets the Full Backup Window Hours
78+
/// </summary>
79+
public int? FullBackupWindowHours { get; set; }
80+
81+
/// <summary>
82+
/// Gets the Log Backup Frequency
83+
/// </summary>
84+
public int? LogBackupFrequency { get; set; }
5585
}
5686
}

src/ResourceManager/Compute/Commands.Compute/Extension/SqlServer/NewAzureVMSqlServerAutoBackupConfig.cs

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Compute.Common;
1516
using Microsoft.Azure.Commands.Common.Authentication;
1617
using Microsoft.Azure.Commands.Common.Authentication.Models;
1718
using Microsoft.Azure.Commands.ResourceManager.Common;
@@ -30,14 +31,12 @@ namespace Microsoft.Azure.Commands.Compute
3031
/// </summary>
3132
[Cmdlet(
3233
VerbsCommon.New,
33-
AzureVMSqlServerAutoBackupConfigNoun,
34+
ProfileNouns.VirtualMachineSqlServerAutoBackupConfig,
3435
DefaultParameterSetName = StorageUriParamSetName),
3536
OutputType(
3637
typeof(AutoBackupSettings))]
3738
public class NewAzureVMSqlServerAutoBackupConfigCommand : AzureRMCmdlet
3839
{
39-
protected const string AzureVMSqlServerAutoBackupConfigNoun = "AzureVMSqlServerAutoBackupConfig";
40-
4140
protected const string StorageContextParamSetName = "StorageContextSqlServerAutoBackup";
4241
protected const string StorageUriParamSetName = "StorageUriSqlServerAutoBackup";
4342

@@ -117,6 +116,77 @@ public SecureString StorageKey
117116
set;
118117
}
119118

119+
[Parameter(
120+
Mandatory = false,
121+
Position = 6,
122+
ValueFromPipelineByPropertyName = true,
123+
HelpMessage = "Backup system databases")]
124+
public SwitchParameter BackupSystemDbs
125+
{
126+
get;
127+
set;
128+
}
129+
130+
[Parameter(
131+
Mandatory = false,
132+
Position = 7,
133+
ValueFromPipelineByPropertyName = true,
134+
HelpMessage = "Backup schedule type, manual or automated")]
135+
[ValidateSet("Manual", "Automatic")]
136+
public string BackupScheduleType
137+
{
138+
get;
139+
set;
140+
}
141+
142+
[Parameter(
143+
Mandatory = false,
144+
Position = 8,
145+
ValueFromPipelineByPropertyName = true,
146+
HelpMessage = "Sql Server Full Backup frequency, daily or weekly")]
147+
[ValidateSet("Daily", "Weekly")]
148+
public string FullBackupFrequency
149+
{
150+
get;
151+
set;
152+
}
153+
154+
[Parameter(
155+
Mandatory = false,
156+
Position = 9,
157+
ValueFromPipelineByPropertyName = true,
158+
HelpMessage = "Hour of the day (0-23) when the Sql Server Full Backup should start")]
159+
[ValidateRange(0,23)]
160+
public int FullBackupStartHour
161+
{
162+
get;
163+
set;
164+
}
165+
166+
[Parameter(
167+
Mandatory = false,
168+
Position = 10,
169+
ValueFromPipelineByPropertyName = true,
170+
HelpMessage = "Sql Server Full Backup window in hours")]
171+
[ValidateRange(1, 23)]
172+
public int FullBackupWindowInHours
173+
{
174+
get;
175+
set;
176+
}
177+
178+
[Parameter(
179+
Mandatory = false,
180+
Position = 11,
181+
ValueFromPipelineByPropertyName = true,
182+
HelpMessage = "Sql Server Log Backup frequency, once every 1-60 minutes")]
183+
[ValidateRange(1, 60)]
184+
public int LogBackupFrequencyInMinutes
185+
{
186+
get;
187+
set;
188+
}
189+
120190
/// <summary>
121191
/// Initialzies a new instance of the <see cref="NewAzureVMSqlServerAutoBackupConfigCommand"/> class.
122192
/// </summary>
@@ -151,6 +221,17 @@ protected override void ProcessRecord()
151221
// Check if certificate password was set
152222
autoBackupSettings.Password = (CertificatePassword == null) ? null : ConvertToUnsecureString(CertificatePassword);
153223

224+
autoBackupSettings.BackupSystemDbs = BackupSystemDbs.IsPresent ? BackupSystemDbs.ToBool() : false;
225+
autoBackupSettings.BackupScheduleType = BackupScheduleType;
226+
227+
// Set other Backup schedule settings only if BackUpSchedule type is Manual.
228+
if (!string.IsNullOrEmpty(BackupScheduleType) && BackupScheduleType == "Manual") {
229+
autoBackupSettings.FullBackupFrequency = FullBackupFrequency;
230+
autoBackupSettings.FullBackupStartTime = FullBackupStartHour;
231+
autoBackupSettings.FullBackupWindowHours = FullBackupWindowInHours;
232+
autoBackupSettings.LogBackupFrequency = LogBackupFrequencyInMinutes;
233+
}
234+
154235
WriteObject(autoBackupSettings);
155236
}
156237

src/ResourceManager/Compute/Commands.Compute/Extension/SqlServer/NewAzureVMSqlServerAutoPatchingConfig.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Management.Automation;
16+
using Microsoft.Azure.Commands.Compute.Common;
1617

1718
namespace Microsoft.Azure.Commands.Compute
1819
{
@@ -21,13 +22,11 @@ namespace Microsoft.Azure.Commands.Compute
2122
/// </summary>
2223
[Cmdlet(
2324
VerbsCommon.New,
24-
AzureVMSqlServerAutoPatchingConfigNoun),
25+
ProfileNouns.VirtualMachineSqlServerAutoPatchingConfig),
2526
OutputType(
2627
typeof(AutoPatchingSettings))]
2728
public class NewAzureVMSqlServerAutoPatchingConfigCommand : PSCmdlet
2829
{
29-
protected const string AzureVMSqlServerAutoPatchingConfigNoun = "AzureVMSqlServerAutoPatchingConfig";
30-
3130
[Parameter]
3231
public SwitchParameter Enable { get; set; }
3332

src/ResourceManager/Compute/Commands.Compute/Extension/SqlServer/NewAzureVMSqlServerKeyVaultCredentialConfig.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Security.Permissions;
1818
using System;
1919
using System.Runtime.InteropServices;
20+
using Microsoft.Azure.Commands.Compute.Common;
2021

2122
namespace Microsoft.Azure.Commands.Compute
2223
{
@@ -25,17 +26,12 @@ namespace Microsoft.Azure.Commands.Compute
2526
/// </summary>
2627
[Cmdlet(
2728
VerbsCommon.New,
28-
AzureVMSqlServerKeyVaultCredentialConfigNoun,
29+
ProfileNouns.VirtualMachineSqlServerKeyVaultCredentialConfig,
2930
SupportsShouldProcess = true),
3031
OutputType(
3132
typeof(KeyVaultCredentialSettings))]
3233
public class NewAzureVMSqlServerKeyVaultCredentialConfigCommand : PSCmdlet
3334
{
34-
/// <summary>
35-
/// Configuration object friendly name
36-
/// </summary>
37-
protected const string AzureVMSqlServerKeyVaultCredentialConfigNoun = "AzureVMSqlServerKeyVaultCredentialConfig";
38-
3935
[Parameter(
4036
Mandatory = true,
4137
Position = 0,

0 commit comments

Comments
 (0)