Skip to content

Commit 795eee7

Browse files
Code Changes:
------------- 1) ARM cmdlets for SQLVM extension added ( followed DSC's ARM cmdlet pattern ) 2) supports configuring auto patching in ARM mode 3) supports configuring auto backup in ARM mode 4) Get sqlvm extension status in ARM mode 5) remove sqlvm extension in ARM mode Pending Open issues: ------------------ - MAML file generation & help documentation - adding new functional tests - follow up with Azure team to check why Extenstion statusus were always returning null in Get-* cmdlet Testing: ------ Environment: SQLVM created via new Azure portal using ARM Powershell script used: ----------------------- Switch-AzureMode -Name AzureResourceManager $subscriptionName = "__Subscription__" $vmName = "__vm_name__" $resourceGroupName = "__resourcegroupName__" Add-azureaccount select-azuresubscription -SubscriptionName $subscriptionName # Get Azure VM created using ARM $vm = get-azurevm -ResourceGroupName $resourceGroupName -Name $vmName ########### #Set auto patching ########### $aps = New-AzureVMSqlServerAutoPatchingConfig -Enable -DayOfWeek "EveryDay" -MaintenanceWindowStartingHour 20 -MaintenanceWindowDuration 120 -PatchCategory "Important" $vm | Set-AzureVMSqlServerExtension -AutoPatchingSettings $aps -ResourceGroupName $resourceGroupName -VMName $vmName -Version "1.2" -Verbose ########### #Set auto backup ########### $storageUrl = "https://__account__.blob.core.windows.net/" $storageAccountKey = "__KEY__" $storageAccountKeySecure = convertto-securestring $storageAccountKey -asplaintext -force $abs = New-AzureVMSqlServerAutoBackupConfig -Enable -RetentionPeriod 22 -StorageUri $storageUrl -StorageKey $storageAccountKeySecure $vm = get-azurevm -ResourceGroupName $resourceGroupName -Name $vmName $vm | Set-AzureVMSqlServerExtension -AutoBackupSettings $abs -ResourceGroupName $resourceGroupName -VMName $vmName -Version "1.2" -Verbose ########### #get extension status ########### Get-AzureVMSqlServerExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $vmName ########### #remove extension ########### Remove-AzureVMSqlServerExtension -ResourceGroupName $resourceGroupName -VMName $vmName -Name $vmName Task# 5468533 - SQL IaaS Extension PowerShell Resource Management support
1 parent b3b331c commit 795eee7

15 files changed

+969
-0
lines changed

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@
223223
<Compile Include="Extension\SetAzureVMExtensionCommand.cs" />
224224
<Compile Include="Extension\RemoveAzureVMExtensionCommand.cs" />
225225
<Compile Include="Extension\GetAzureVMExtensionCommand.cs" />
226+
<Compile Include="Extension\SqlServer\AzureVMSqlServerAutoBackupSettings.cs" />
227+
<Compile Include="Extension\SqlServer\AzureVMSqlServerAutoPatchingSettings.cs" />
228+
<Compile Include="Extension\SqlServer\AzureVMSqlServerAutoTelemetrySettings.cs" />
229+
<Compile Include="Extension\SqlServer\AzureVMSqlServerPrivateSettings.cs" />
230+
<Compile Include="Extension\SqlServer\AzureVMSqlServerPublicSettings.cs" />
231+
<Compile Include="Extension\SqlServer\GetAzureVMSqlServerExtensionCommand.cs" />
232+
<Compile Include="Extension\SqlServer\NewAzureVMSqlServerAutoBackupConfig.cs" />
233+
<Compile Include="Extension\SqlServer\NewAzureVMSqlServerAutoPatchingConfig.cs" />
234+
<Compile Include="Extension\SqlServer\RemoveAzureVMSqlServerExtensionCommand.cs" />
235+
<Compile Include="Extension\SqlServer\SetAzureVMSqlServerExtensionCommand.cs" />
236+
<Compile Include="Extension\SqlServer\VirtualMachineSqlServerExtensionContext.cs" />
226237
<Compile Include="Images\GetAzureVMImageCommand.cs" />
227238
<Compile Include="Common\HashTableExtensions.cs" />
228239
<Compile Include="Models\PSComputeLongRunningOperation.cs" />

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,8 @@ public static class ProfileNouns
9797
//DSC
9898
public const string VirtualMachineDscExtension = "AzureVMDscExtension";
9999
public const string VirtualMachineDscConfiguration = "AzureVMDscConfiguration";
100+
101+
// Sql Server
102+
public const string VirtualMachineSqlServerExtension = "AzureVMSqlServerExtension";
100103
}
101104
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Compute
16+
{
17+
/// <summary>
18+
/// Autobackup settings to configure managed backup on SQL VM
19+
/// </summary>
20+
public class AutoBackupSettings
21+
{
22+
/// <summary>
23+
/// Defines if the Auto-backup feature is enabled or disabled
24+
/// </summary>
25+
public bool Enable { get; set; }
26+
27+
/// <summary>
28+
/// Defines if backups will be encrypted or not
29+
/// </summary>
30+
public bool EnableEncryption { get; set; }
31+
32+
/// <summary>
33+
/// Defines the number of days to keep the backups
34+
/// </summary>
35+
public int RetentionPeriod { get; set; }
36+
37+
/// <summary>
38+
/// storage url where databases will be backed up
39+
/// </summary>
40+
public string StorageUrl { get; set; }
41+
42+
/// <summary>
43+
/// Key of storage account used by managed backup
44+
/// </summary>
45+
public string StorageAccessKey { get; set; }
46+
47+
/// <summary>
48+
/// Password required for certification when encryption is enabled
49+
/// </summary>
50+
public string Password { get; set; }
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Compute
16+
{
17+
/// <summary>
18+
/// AutoPatching settings to configure auto-patching on SQL VM
19+
/// </summary>
20+
public class AutoPatchingSettings
21+
{
22+
/// <summary>
23+
/// Enable / Disable auto patching
24+
/// </summary>
25+
public bool Enable { get; set; }
26+
27+
/// <summary>
28+
/// Day of the week
29+
/// </summary>
30+
public string DayOfWeek { get; set; }
31+
32+
/// <summary>
33+
/// Maintainance Windows Start hour ( 0 to 23 )
34+
/// </summary>
35+
public int MaintenanceWindowStartingHour { get; set; }
36+
37+
/// <summary>
38+
/// Maintainance window duration in minutes
39+
/// </summary>
40+
public int MaintenanceWindowDuration { get; set; }
41+
42+
/// <summary>
43+
/// Patch category returned as string
44+
/// </summary>
45+
public string PatchCategory { get; set; }
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Compute
16+
{
17+
/// <summary>
18+
/// AutoTelemetry settings to configure telemetry collection on SQL VM
19+
/// </summary>
20+
public class AutoTelemetrySettings
21+
{
22+
/// <summary>
23+
/// The name of the region the VM is running in.
24+
/// </summary>
25+
public string Region { get; set; }
26+
}
27+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Compute
16+
{
17+
/// <summary>
18+
/// SQL Server extension's private settings
19+
/// </summary>
20+
public class SqlServerPrivateSettings
21+
{
22+
/// <summary>
23+
/// Azure blob store URL
24+
/// </summary>
25+
public string StorageUrl;
26+
27+
/// <summary>
28+
/// Storage account access key
29+
/// </summary>
30+
public string StorageAccessKey;
31+
32+
/// <summary>
33+
/// Password required for certification when encryption is enabled
34+
/// </summary>
35+
public string Password;
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Compute
16+
{
17+
/// <summary>
18+
/// SQL Server Extension's public settings
19+
/// </summary>
20+
public class SqlServerPublicSettings
21+
{
22+
/// <summary>
23+
/// Auto patching settings
24+
/// </summary>
25+
public AutoPatchingSettings AutoPatchingSettings { get; set; }
26+
27+
/// <summary>
28+
/// Auto-backup settings
29+
/// </summary>
30+
public AutoBackupSettings AutoBackupSettings { get; set; }
31+
32+
/// <summary>
33+
/// Auto-telemetry settings
34+
/// </summary>
35+
public AutoTelemetrySettings AutoTelemetrySettings { get; set; }
36+
}
37+
}

0 commit comments

Comments
 (0)