Skip to content

Commit c437ebe

Browse files
committed
commit
1 parent 1001d5a commit c437ebe

File tree

6 files changed

+279
-9
lines changed

6 files changed

+279
-9
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/ServiceClientHelpers.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public static string GetServiceClientProviderType(CmdletModel.WorkloadType workl
7676
case CmdletModel.WorkloadType.AzureFiles:
7777
providerType = ServiceClientModel.BackupManagementType.AzureStorage.ToString();
7878
break;
79+
case CmdletModel.WorkloadType.MSSQL:
80+
providerType = ServiceClientModel.BackupManagementType.AzureWorkload.ToString();
81+
break;
7982
default:
8083
break;
8184
}
@@ -353,4 +356,4 @@ public static string GetServiceClientWorkloadType(CmdletModel.WorkloadType workl
353356
return serviceClientWorkloadType;
354357
}
355358
}
356-
}
359+
}

src/RecoveryServices/RecoveryServices.Backup.Models/CommonModels/Enums.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ public enum ContainerType
3737
/// <summary>
3838
/// Represents any Azure Storage containers.
3939
/// </summary>
40-
AzureStorage
40+
AzureStorage,
41+
42+
/// <summary>
43+
/// Represents any Azure Workload containers.
44+
/// </summary>
45+
AzureWorkload
4146
}
4247

4348
/// <summary>
@@ -70,6 +75,7 @@ public enum BackupManagementType
7075
/// Represents Azure File Storage. https://docs.microsoft.com/en-in/azure/storage/files/storage-files-introduction
7176
/// </summary>
7277
AzureStorage,
78+
AzureWorkload,
7379
}
7480

7581
/// <summary>
@@ -103,6 +109,7 @@ public enum WorkloadType
103109
/// Represents Azure File https://docs.microsoft.com/en-in/azure/storage/files/storage-files-introduction
104110
/// </summary>
105111
AzureFiles,
112+
MSSQL,
106113
}
107114

108115
/// <summary>
@@ -134,6 +141,7 @@ public enum PsBackupProviderTypes
134141
/// Represents the Azure File provider for powershell cmdlets.
135142
/// </summary>
136143
AzureFiles,
144+
AzureWorkload,
137145
}
138146

139147
/// <summary>
@@ -334,4 +342,4 @@ public enum SourceFileType
334342
File,
335343
Directory
336344
}
337-
}
345+
}

src/RecoveryServices/RecoveryServices.Backup.Models/CommonModels/Utils.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ public static BackupManagementType GetPsBackupManagementType(string backupManage
218218
return BackupManagementType.AzureSQL;
219219
case ServiceClientModel.BackupManagementType.AzureStorage:
220220
return BackupManagementType.AzureStorage;
221+
case ServiceClientModel.BackupManagementType.AzureWorkload:
222+
return BackupManagementType.AzureWorkload;
221223
default:
222224
throw new Exception("Unsupported BackupManagmentType: " + backupManagementType);
223225
}
@@ -248,6 +250,11 @@ public static ContainerType GetPsContainerType(string containerType)
248250
{
249251
return ContainerType.AzureStorage;
250252
}
253+
else if (containerType ==
254+
ServiceClientModel.BackupManagementType.AzureWorkload)
255+
{
256+
return ContainerType.AzureWorkload;
257+
}
251258
else
252259
{
253260
throw new Exception("Unsupported ContainerType: " + containerType);
@@ -265,14 +272,18 @@ public static WorkloadType GetPsWorkloadType(string workloadType)
265272
{
266273
return WorkloadType.AzureVM;
267274
}
268-
if (workloadType == ServiceClientModel.WorkloadType.AzureSqlDb.ToString())
275+
else if (workloadType == ServiceClientModel.WorkloadType.AzureSqlDb.ToString())
269276
{
270277
return WorkloadType.AzureSQLDatabase;
271278
}
272-
if (workloadType == ServiceClientModel.WorkloadType.AzureFileShare)
279+
else if (workloadType == ServiceClientModel.WorkloadType.AzureFileShare)
273280
{
274281
return WorkloadType.AzureFiles;
275282
}
283+
else if (workloadType == ServiceClientModel.WorkloadType.SQLDataBase)
284+
{
285+
return WorkloadType.MSSQL;
286+
}
276287
else
277288
{
278289
throw new Exception("Unsupported WorkloadType: " + workloadType);
@@ -290,14 +301,18 @@ public static string GetServiceClientWorkloadType(string workloadType)
290301
{
291302
return ServiceClientModel.WorkloadType.VM;
292303
}
293-
if (workloadType == WorkloadType.AzureSQLDatabase.ToString())
304+
else if (workloadType == WorkloadType.AzureSQLDatabase.ToString())
294305
{
295306
return ServiceClientModel.WorkloadType.AzureSqlDb;
296307
}
297-
if (workloadType == WorkloadType.AzureFiles.ToString())
308+
else if (workloadType == WorkloadType.AzureFiles.ToString())
298309
{
299310
return ServiceClientModel.WorkloadType.AzureFileShare;
300311
}
312+
else if (workloadType == WorkloadType.MSSQL.ToString())
313+
{
314+
return ServiceClientModel.WorkloadType.SQLDataBase;
315+
}
301316
else
302317
{
303318
throw new Exception("Unsupported WorkloadType: " + workloadType);
@@ -343,4 +358,4 @@ public static string GetWorkloadTypeFromArmType(string armType)
343358
throw new Exception("Unsupported ArmType: " + armType);
344359
}
345360
}
346-
}
361+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\..\..\tools\Common.Dependencies.targets" />
4+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5+
<PropertyGroup>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{02234E90-BCDE-4B20-B1F5-01B1005821DB}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Microsoft.Azure.Commands.RecoveryServices.Backup.Providers</RootNamespace>
12+
<AssemblyName>Microsoft.Azure.Commands.RecoveryServices.Backup.Providers</AssemblyName>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
<DefineConstants>TRACE;SIGN</DefineConstants>
33+
<SignAssembly>true</SignAssembly>
34+
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
35+
<DelaySign>true</DelaySign>
36+
<Prefer32Bit>false</Prefer32Bit>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
40+
<SpecificVersion>False</SpecificVersion>
41+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.3.0.1-preview\lib\net452\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
42+
</Reference>
43+
<Reference Include="System" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Net" />
46+
<Reference Include="System.Net.Http" />
47+
<Reference Include="System.ServiceProcess" />
48+
<Reference Include="System.Xml.Linq" />
49+
<Reference Include="System.Data.DataSetExtensions" />
50+
<Reference Include="Microsoft.CSharp" />
51+
<Reference Include="System.Data" />
52+
<Reference Include="System.Xml" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Compile Include="AzureWorkloadProviderHelper.cs" />
56+
<Compile Include="IPsBackupProvider.cs" />
57+
<Compile Include="Properties\AssemblyInfo.cs" />
58+
<Compile Include="Providers\AzureFilesPsBackupProvider.cs" />
59+
<Compile Include="Providers\AzureSqlPsBackupProvider.cs" />
60+
<Compile Include="Providers\AzureWorkloadPsBackupProvider.cs" />
61+
<Compile Include="Providers\DpmPsBackupProvider.cs" />
62+
<Compile Include="Providers\MabPsBackupProvider.cs" />
63+
<Compile Include="PsBackupProviderManager.cs" />
64+
<Compile Include="Providers\IaasVmPsBackupProvider.cs" />
65+
</ItemGroup>
66+
<ItemGroup>
67+
<ProjectReference Include="..\..\Profile\Commands.Profile\Commands.Profile.csproj">
68+
<Project>{142d7b0b-388a-4ceb-a228-7f6d423c5c2e}</Project>
69+
<Name>Commands.Profile</Name>
70+
</ProjectReference>
71+
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Helpers\Commands.RecoveryServices.Backup.Helpers.csproj">
72+
<Project>{0e1d3f36-e6c8-4764-8c7d-6f9ee537490c}</Project>
73+
<Name>Commands.RecoveryServices.Backup.Helpers</Name>
74+
</ProjectReference>
75+
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Logger\Commands.RecoveryServices.Backup.Logger.csproj">
76+
<Project>{5e675749-6139-464a-904c-59c0ffdfec82}</Project>
77+
<Name>Commands.RecoveryServices.Backup.Logger</Name>
78+
</ProjectReference>
79+
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Models\Commands.RecoveryServices.Backup.Models.csproj">
80+
<Project>{30b92759-50b3-494e-b9f0-ec9a2ce9d57b}</Project>
81+
<Name>Commands.RecoveryServices.Backup.Models</Name>
82+
</ProjectReference>
83+
<ProjectReference Include="..\Commands.RecoveryServices.Backup.ServiceClientAdapter\Commands.RecoveryServices.Backup.ServiceClientAdapter.csproj">
84+
<Project>{b758fec1-35c1-4f93-a954-66dd33f6e0ec}</Project>
85+
<Name>Commands.RecoveryServices.Backup.ServiceClientAdapter</Name>
86+
</ProjectReference>
87+
</ItemGroup>
88+
<ItemGroup>
89+
<None Include="MSSharedLibKey.snk" />
90+
<None Include="packages.config" />
91+
</ItemGroup>
92+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
93+
</Project>
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ServiceClientAdapterNS;
17+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
18+
using System;
19+
using System.Collections.Generic;
20+
using CmdletModel = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
21+
using RestAzureNS = Microsoft.Rest.Azure;
22+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
23+
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
24+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
25+
26+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel
27+
{
28+
/// <summary>
29+
/// This class implements methods for azure DB Workload backup provider
30+
/// </summary>
31+
public class AzureWorkloadPsBackupProvider : IPsBackupProvider
32+
{
33+
private const int defaultOperationStatusRetryTimeInMilliSec = 5 * 1000; // 5 sec
34+
private const string separator = ";";
35+
private const CmdletModel.RetentionDurationType defaultFileRetentionType =
36+
CmdletModel.RetentionDurationType.Days;
37+
private const int defaultFileRetentionCount = 30;
38+
Dictionary<Enum, object> ProviderData { get; set; }
39+
ServiceClientAdapter ServiceClientAdapter { get; set; }
40+
AzureWorkloadProviderHelper AzureWorkloadProviderHelper { get; set; }
41+
/// <summary>
42+
/// Initializes the provider with the data recieved from the cmdlet layer
43+
/// </summary>
44+
/// <param name="providerData">Data from the cmdlet layer intended for the provider</param>
45+
/// <param name="serviceClientAdapter">Service client adapter for communicating with the backend service</param>
46+
public void Initialize(Dictionary<Enum, object> providerData, ServiceClientAdapter serviceClientAdapter)
47+
{
48+
ProviderData = providerData;
49+
ServiceClientAdapter = serviceClientAdapter;
50+
AzureWorkloadProviderHelper = new AzureWorkloadProviderHelper(ServiceClientAdapter);
51+
}
52+
53+
public ResourceBackupStatus CheckBackupStatus()
54+
{
55+
throw new NotImplementedException();
56+
}
57+
58+
public ProtectionPolicyResource CreatePolicy()
59+
{
60+
throw new NotImplementedException();
61+
}
62+
63+
public RestAzureNS.AzureOperationResponse DisableProtection()
64+
{
65+
throw new NotImplementedException();
66+
}
67+
68+
public RestAzureNS.AzureOperationResponse EnableProtection()
69+
{
70+
throw new NotImplementedException();
71+
}
72+
73+
public RetentionPolicyBase GetDefaultRetentionPolicyObject()
74+
{
75+
throw new NotImplementedException();
76+
}
77+
78+
public SchedulePolicyBase GetDefaultSchedulePolicyObject()
79+
{
80+
throw new NotImplementedException();
81+
}
82+
83+
public ProtectedItemResource GetProtectedItem()
84+
{
85+
throw new NotImplementedException();
86+
}
87+
88+
public RecoveryPointBase GetRecoveryPointDetails()
89+
{
90+
throw new NotImplementedException();
91+
}
92+
93+
public List<CmdletModel.BackupEngineBase> ListBackupManagementServers()
94+
{
95+
throw new NotImplementedException();
96+
}
97+
98+
public List<ItemBase> ListProtectedItems()
99+
{
100+
throw new NotImplementedException();
101+
}
102+
103+
public List<ContainerBase> ListProtectionContainers()
104+
{
105+
throw new NotImplementedException();
106+
}
107+
108+
public List<RecoveryPointBase> ListRecoveryPoints()
109+
{
110+
throw new NotImplementedException();
111+
}
112+
113+
public RestAzureNS.AzureOperationResponse<ProtectionPolicyResource> ModifyPolicy()
114+
{
115+
throw new NotImplementedException();
116+
}
117+
118+
public RPMountScriptDetails ProvisionItemLevelRecoveryAccess()
119+
{
120+
throw new NotImplementedException();
121+
}
122+
123+
public void RevokeItemLevelRecoveryAccess()
124+
{
125+
throw new NotImplementedException();
126+
}
127+
128+
public RestAzureNS.AzureOperationResponse TriggerBackup()
129+
{
130+
throw new NotImplementedException();
131+
}
132+
133+
public RestAzureNS.AzureOperationResponse TriggerRestore()
134+
{
135+
throw new NotImplementedException();
136+
}
137+
}
138+
}

0 commit comments

Comments
 (0)