Skip to content

Commit c1a0878

Browse files
authored
initial commit (Azure#13680)
1 parent ff4d800 commit c1a0878

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/RecoveryServices/RecoveryServices.Backup.Models/AzureVmWorkloadModels/AzureWorkloadSQLDatabaseProtectedItem.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ public AzureWorkloadSQLDatabaseProtectedItem(ProtectedItemResource protectedItem
8282
ProtectionState =
8383
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
8484
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
85+
DateOfPurge = null;
86+
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("NotDeleted");
87+
if (protectedItem.IsScheduledForDeferredDelete.HasValue)
88+
{
89+
DateOfPurge = protectedItem.DeferredDeleteTimeInUTC.Value.AddDays(14);
90+
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("ToBeDeleted");
91+
}
8592
}
8693
}
8794

src/RecoveryServices/RecoveryServices.Backup.Providers/Providers/AzureWorkloadPsBackupProvider.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,32 @@ public RestAzureNS.AzureOperationResponse DisableProtectionWithDeleteData()
104104

105105
public RestAzureNS.AzureOperationResponse<ProtectedItemResource> UndeleteProtection()
106106
{
107-
throw new Exception(Resources.SoftdeleteNotImplementedException);
107+
string vaultName = (string)ProviderData[VaultParams.VaultName];
108+
string resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];
109+
AzureWorkloadSQLDatabaseProtectedItem item = (AzureWorkloadSQLDatabaseProtectedItem)ProviderData[ItemParams.Item];
110+
111+
Dictionary<UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id);
112+
string containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id);
113+
string protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id);
114+
115+
AzureVmWorkloadSQLDatabaseProtectedItem properties = new AzureVmWorkloadSQLDatabaseProtectedItem();
116+
117+
properties.PolicyId = null;
118+
properties.ProtectionState = ProtectionState.ProtectionStopped;
119+
properties.SourceResourceId = item.SourceResourceId;
120+
properties.IsRehydrate = true;
121+
122+
ProtectedItemResource serviceClientRequest = new ProtectedItemResource()
123+
{
124+
Properties = properties,
125+
};
126+
127+
return ServiceClientAdapter.CreateOrUpdateProtectedItem(
128+
containerUri,
129+
protectedItemUri,
130+
serviceClientRequest,
131+
vaultName: vaultName,
132+
resourceGroupName: resourceGroupName);
108133
}
109134

110135
public RestAzureNS.AzureOperationResponse<ProtectedItemResource> EnableProtection()

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Enabled softdelete feature for SQL.
2122

2223
## Version 3.1.0
2324
* Made help text and parameter set name changes to `Restore-AzRecoveryServicesBackupItem` cmdlet.

0 commit comments

Comments
 (0)