Skip to content

Commit f58f00b

Browse files
pragrawamarkcowl
authored andcommitted
[RS Backup] Azure SQL workload support and new features in Azure VM workload (#2519)
* 1.Added backup support for Azure SQL workload 2.Added capability to specify retention of recovery point during backup 3.Added backup support for Encrypted VMs in the Azure VM workload * Removing SubType in csproj, format ps1 xml indent Correction and adding storage package in package.config * Adding summary to public functions for Azure sql * Indentation in RecoveryPointConversion.cs and summary fix in AzureSqlRecoveryPoint.cs * Uncommenting RecoveryServices.Backup test assembly, update error message for blob storage account, making resource id parsing generic * [RS Backup] Addressed review comments, fixed a few minor bugs 1. Long line breaks. Set 100 as the line length limit 2. Fixed bug: Get-AzureRmRecoveryServicesBackupContainer printing internal Vm Unique Id as Name 3. Added Deprecation message for Name filter in Get-AzureRmRecoveryServicesBackupContainer and introduced FriendlyName filter 4. Fixed resource group filter case-sensitive issue in Get-Item cmdlet * [RS Backup] Adding csproj reference to Commands.RecoveryServices in Tests project * [RS Backup] Onboarding RS Backup Tests project onto test targets * [RS Backup] Added RecoveryServices module to test setup * [RS Backup] Universal time fix in test * [RS Backup] Universal time fix in job tests * Excluding change for blocking blob storage account for restore * [RS Backup] Removed hardcoded location in vault tests * [RS Backup] Returning single location instead of array of locations in get_available_location function * [RS Backup] Making the vault location parameter local to test functions * [RS Backup] Fixing a test issue - using absolute path when doing path check * [RS Backup] bug fix - Get Recovery Point Id is returning incorrect ContainerName and ItemName in Powershell
1 parent e8dee90 commit f58f00b

File tree

78 files changed

+13908
-1561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+13908
-1561
lines changed

AzurePowershell.Test.targets

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<ScenarioTestDebug>.\src\ServiceManagement\Common\Commands.ScenarioTest\bin\Debug\Microsoft.WindowsAzure.Commands.ScenarioTest.dll</ScenarioTestDebug>
99
<CommonTestDebug>.\src\ServiceManagement\Common\Commands.Common.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Common.Test.dll</CommonTestDebug>
1010
<BackupTestDebug>.\src\ResourceManager\AzureBackup\Commands.AzureBackup.Test\bin\Debug\Microsoft.Azure.Commands.AzureBackup.Test.dll</BackupTestDebug>
11+
<RecoveryServicesBackupTestDebug>.\src\ResourceManager\AzureBackup\Commands.RecoveryServices.Backup.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll</RecoveryServicesBackupTestDebug>
1112
<SiteRecoveryTestDebug>.\src\ResourceManager\SiteRecovery\Commands.SiteRecovery.Test\bin\Debug\Microsoft.Azure.Commands.SiteRecovery.Test.dll</SiteRecoveryTestDebug>
1213
<SqlTestDebug>.\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll</SqlTestDebug>
1314
<ComputeDebug>.\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.dll</ComputeDebug>
@@ -98,8 +99,8 @@
9899
<XUnitTests Include=".\src\ResourceManager\DevTestLabs\Commands.DevTestLabs.Test\bin\Debug\Microsoft.Azure.Commands.DevTestLabs.Test.dll"/>
99100
<XUnitTests Include=".\src\ResourceManager\HDInsight\Commands.HDInsight.Test\bin\Debug\Commands.HDInsight.Test.dll"/>
100101
<XUnitTests Include=".\src\ResourceManager\Insights\Commands.Insights.Test\bin\Debug\Microsoft.Azure.Commands.Insights.Test.dll"/>
101-
<XUnitTests Include=".\src\ResourceManager\RecoveryServices\Commands.RecoveryServices.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServicesArm.Test.dll"/>
102-
<XUnitTests Include=".\src\ResourceManager\RecoveryServices.Backup\Commands.RecoveryServices.Backup.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll"/> -->
102+
<XUnitTests Include=".\src\ResourceManager\RecoveryServices\Commands.RecoveryServices.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServicesArm.Test.dll"/> -->
103+
<XUnitTests Include=".\src\ResourceManager\RecoveryServices.Backup\Commands.RecoveryServices.Backup.Test\bin\Debug\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.dll"/>
103104
<XUnitTests Include=".\src\ResourceManager\RedisCache\Commands.RedisCache.Test\bin\Debug\Microsoft.Azure.Commands.RedisCache.Test.dll"/>
104105
<!--<XUnitTests Include=".\src\ResourceManager\ServerManagement\Commands.ServerManagement.Test\bin\Debug\Microsoft.Azure.Commands.ServerManagement.Test.dll"/>
105106
<XUnitTests Include=".\src\ResourceManager\Storage\Commands.Management.Storage.Test\bin\Debug\Microsoft.Azure.Commands.Management.Storage.Test.dll"/>-->
@@ -282,6 +283,13 @@
282283
IncludeTraits="$(XUnitIncludedTrait)" MaxParallelThreads="0" ParallelizeAssemblies="false" ParallelizeTestCollections="false"/>
283284
</Target>
284285

286+
<!-- Run the Recovery Services backup tests -->
287+
<Target Name="RecoveryServicesBackupTests">
288+
<Message Importance="high" Text="Running Recovery Services Backup tests" />
289+
<Xunit.Runner.MSBuild.xunit Assemblies="$(RecoveryServicesBackupTestDebug)" Html="$(TestOutputDirectory)\RecoveryServicesBackupTests.xunit.dll.html" Verbose="false"
290+
IncludeTraits="$(XUnitIncludedTrait)" MaxParallelThreads="0" ParallelizeAssemblies="false" ParallelizeTestCollections="false"/>
291+
</Target>
292+
285293
<!-- Run the common tests -->
286294
<Target Name="CommonTests">
287295
<Message Importance="high" Text="Running Common tests" />

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Commands.RecoveryServices.Backup.Helpers.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</Reference>
4343
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
4444
<SpecificVersion>False</SpecificVersion>
45-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.0.1.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
45+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.0.1.2\lib\net40\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
4646
</Reference>
4747
<Reference Include="System" />
4848
<Reference Include="System.Core" />
@@ -57,6 +57,7 @@
5757
<Compile Include="Conversions\JobConversions.cs" />
5858
<Compile Include="Conversions\RecoveryPointConversions.cs" />
5959
<Compile Include="HelperUtils.cs" />
60+
<Compile Include="TrackingHelpers.cs" />
6061
<Compile Include="Validations\PolicyValidations.cs" />
6162
<Compile Include="Conversions\SchedulePolicyConversions.cs" />
6263
<Compile Include="Conversions\RetentionPolicyConversions.cs" />
@@ -80,7 +81,8 @@
8081
</ItemGroup>
8182
<ItemGroup>
8283
<None Include="MSSharedLibKey.snk" />
83-
<None Include="packages.config" />
84+
<None Include="packages.config">
85+
</None>
8486
</ItemGroup>
8587
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8688
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta
4949
{
5050
containerModel = new MabContainer(protectionContainer);
5151
}
52+
else if (protectionContainer.Properties.GetType() ==
53+
typeof(ServiceClientModel.AzureSqlProtectionContainer))
54+
{
55+
containerModel = new AzureSqlContainer(protectionContainer);
56+
}
5257
}
5358

5459
return containerModel;
@@ -153,6 +158,31 @@ public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResou
153158
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((ServiceClientModel.SimpleSchedulePolicy)
154159
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy);
155160
}
161+
else if (serviceClientResponse.Properties.GetType() ==
162+
typeof(ServiceClientModel.AzureSqlProtectionPolicy))
163+
{
164+
ServiceClientModel.AzureSqlProtectionPolicy azureSqlPolicy =
165+
(ServiceClientModel.AzureSqlProtectionPolicy)serviceClientResponse.Properties;
166+
167+
if (azureSqlPolicy.RetentionPolicy.GetType() !=
168+
typeof(ServiceClientModel.SimpleRetentionPolicy))
169+
{
170+
Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
171+
azureSqlPolicy.RetentionPolicy.GetType());
172+
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
173+
return null;
174+
}
175+
176+
policyModel = new AzureSqlPolicy();
177+
AzureSqlPolicy sqlPolicyModel = policyModel as AzureSqlPolicy;
178+
sqlPolicyModel.WorkloadType = CmdletModels.WorkloadType.AzureSQLDatabase;
179+
sqlPolicyModel.BackupManagementType = CmdletModels.BackupManagementType.AzureSQL;
180+
181+
ServiceClientModel.SimpleRetentionPolicy azureSqlRetentionPolicy =
182+
(ServiceClientModel.SimpleRetentionPolicy)azureSqlPolicy.RetentionPolicy;
183+
sqlPolicyModel.RetentionPolicy =
184+
PolicyHelpers.GetPSSimpleRetentionPolicy(azureSqlRetentionPolicy);
185+
}
156186
else
157187
{
158188
// we will enter this case when service supports new workload and customer
@@ -233,6 +263,31 @@ public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource pro
233263
Cmdlets.Models.ContainerType.AzureVM,
234264
policyName);
235265
}
266+
267+
if (protectedItem.Properties.GetType() ==
268+
typeof(ServiceClientModel.AzureSqlProtectedItem))
269+
{
270+
ServiceClientModel.AzureSqlProtectedItem azureSqlProtectedItem =
271+
(ServiceClientModel.AzureSqlProtectedItem)protectedItem.Properties;
272+
string policyName = null;
273+
string policyId = azureSqlProtectedItem.PolicyId;
274+
if (!String.IsNullOrEmpty(policyId))
275+
{
276+
Dictionary<UriEnums, string> keyVauleDict =
277+
HelperUtils.ParseUri(policyId);
278+
policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId);
279+
}
280+
281+
string containerUri = HelperUtils.GetContainerUri(
282+
HelperUtils.ParseUri(protectedItem.Id),
283+
protectedItem.Id);
284+
285+
itemModel = new AzureSqlItem(
286+
protectedItem,
287+
IdUtils.GetNameFromUri(containerUri),
288+
Cmdlets.Models.ContainerType.AzureSQL,
289+
policyName);
290+
}
236291
}
237292

238293
return itemModel;

0 commit comments

Comments
 (0)