Skip to content

Commit f2c1af5

Browse files
author
ianna1-admin
committed
ADLS added as backup workload + rename containers feature for ILR
1 parent 2267ada commit f2c1af5

27 files changed

+624
-54
lines changed

src/DataProtection/DataProtection.Autorest/custom/Cmdlets/Platform/BackupInstance/Initialize-AzDataProtectionBackupInstance.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
[Parameter(Mandatory=$false, HelpMessage='Friendly name for backup instance')]
4040
[System.String]
4141
${FriendlyName},
42-
43-
[Parameter(Mandatory=$false, HelpMessage='Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService,AzureBlob.')]
42+
43+
[Parameter(Mandatory=$false, HelpMessage='Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService, AzureBlob and AzureDataLakeStorage.')]
4444
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.IBackupDatasourceParameters]
4545
${BackupConfiguration},
4646

src/DataProtection/DataProtection.Autorest/custom/Cmdlets/Platform/BackupInstance/New-AzDataProtectionBackupConfigurationClientObject.ps1

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function New-AzDataProtectionBackupConfigurationClientObject{
77
param(
88
[Parameter(Mandatory, HelpMessage='Datasource Type')]
99
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Support.DatasourceTypes]
10-
[ValidateSet('AzureKubernetesService', 'AzureBlob')]
10+
[ValidateSet('AzureKubernetesService', 'AzureBlob', 'AzureDataLakeStorage')]
1111
${DatasourceType},
1212

1313
[Parameter(Mandatory=$false, HelpMessage='List of resource types to be excluded from backup')]
@@ -134,6 +134,44 @@ function New-AzDataProtectionBackupConfigurationClientObject{
134134
throw $message
135135
}
136136
}
137+
elseif($DatasourceType.ToString() -eq "AzureDataLakeStorage"){
138+
$dataSourceParam = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.AdlsBlobBackupDatasourceParameters]::new()
139+
$dataSourceParam.ObjectType = "AdlsBlobBackupDatasourceParameters"
140+
141+
if($VaultedBackupContainer -ne $null){
142+
143+
# exclude containers which start with $ except $web, $root
144+
$unsupportedContainers = $VaultedBackupContainer | Where-Object { $_ -like '$*' -and $_ -ne "`$root" -and $_ -ne "`$web"}
145+
if($unsupportedContainers.Count -gt 0){
146+
$message = "Following containers are not allowed for configure protection with AzureDataLakeStorage - $unsupportedContainers. Please remove them and proceed."
147+
throw $message
148+
}
149+
150+
$dataSourceParam.ContainersList = $VaultedBackupContainer
151+
}
152+
elseif($IncludeAllContainer){
153+
if($StorageAccountName -eq $null -or $StorageAccountResourceGroupName -eq $null){
154+
$message = "Please input StorageAccountName and StorageAccountResourceGroupName parameters for fetching all vaulted containers."
155+
throw $message
156+
}
157+
158+
CheckStorageModuleDependency
159+
$storageAccount = Get-AzStorageAccount -ResourceGroupName $StorageAccountResourceGroupName -Name $StorageAccountName
160+
$containers = Get-AzStorageContainer -Context $storageAccount.Context
161+
162+
# exclude containers which start with $ except $web, $root
163+
$allContainers = $containers.Name | Where-Object { -not($_ -like '$*' -and $_ -ne "`$root" -and $_ -ne "`$web")}
164+
$dataSourceParam.ContainersList = $allContainers
165+
}
166+
elseif($ExcludedResourceType -ne $null -or $IncludedResourceType -ne $null -or $ExcludedNamespace -ne $null -or $IncludedNamespace -ne $null -or $LabelSelector -ne $null -or $SnapshotVolume -ne $null -or $IncludeClusterScopeResource -ne $null){
167+
$message = "Invalid parameters ExcludedResourceType, IncludedResourceType, ExcludedNamespace, IncludedNamespace, LabelSelector, SnapshotVolume, IncludeClusterScopeResource for given DatasourceType."
168+
throw $message
169+
}
170+
else {
171+
$message = "Please input VaultedBackupContainer or IncludeAllContainer parameters for given workload type."
172+
throw $message
173+
}
174+
}
137175

138176
$dataSourceParam
139177
}

src/DataProtection/DataProtection.Autorest/custom/Cmdlets/Platform/BackupInstance/Update-AzDataProtectionBackupInstance.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function Update-AzDataProtectionBackupInstance
3636
[System.String]
3737
${UserAssignedIdentityArmId},
3838

39-
[Parameter(Mandatory=$false, HelpMessage='List of containers to be backed up inside the VaultStore. Use this parameter for DatasourceType AzureBlob.')]
39+
[Parameter(Mandatory=$false, HelpMessage='List of containers to be backed up inside the VaultStore. Use this parameter for DatasourceType AzureBlob and AzureDataLakeStorage.')]
4040
[System.String[]]
4141
${VaultedBackupContainer},
4242

@@ -135,15 +135,15 @@ function Update-AzDataProtectionBackupInstance
135135

136136
if($hasVaultedBackupContainer){
137137

138-
if($DatasourceType -ne "AzureBlob"){
138+
if($DatasourceType -ne "AzureBlob" -and $DatasourceType -ne "AzureDataLakeStorage"){
139139
$err = "Parameter VaultedBackupContainer isn't supported for given Datasource"
140140
throw $err
141141
}
142142

143143
# exclude containers which start with $ except $web, $root
144144
$unsupportedContainers = $VaultedBackupContainer | Where-Object { $_ -like '$*' -and $_ -ne "`$root" -and $_ -ne "`$web"}
145145
if($unsupportedContainers.Count -gt 0){
146-
$message = "Following containers are not allowed for configure protection with AzureBlob - $unsupportedContainers. Please remove them and try again."
146+
$message = "Following containers are not allowed for configure protection with AzureBlob and AzureDataLakeStorage - $unsupportedContainers. Please remove them and try again."
147147
throw $message
148148
}
149149

src/DataProtection/DataProtection.Autorest/custom/Cmdlets/Platform/Restore/Initialize-AzDataProtectionRestoreRequest.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
[Hashtable]
108108
${PrefixMatch},
109109

110+
[Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Use this parameter to rename container(s) for alternate location ILR. Input for this parameter is a hashtable where each key is the original container name and each value is the new name for the corresponding container.')]
111+
[Hashtable]
112+
${RenameTo},
113+
110114
[Parameter(ParameterSetName="OriginalLocationILR", Mandatory=$false, HelpMessage='Specify the blob restore start range for PITR. You can use this option to specify the starting range for a subset of blobs in each container to restore. use a forward slash (/) to separate the container name from the blob prefix pattern.')]
111115
# [Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Minimum matching value for Item Level Recovery.')]
112116
[System.String[]]
@@ -296,6 +300,7 @@
296300

297301
if(($RecoveryPoint -ne $null) -and ($RecoveryPoint -ne "") -and $ContainersList.length -gt 0){
298302
$hasPrefixMatch = $PSBoundParameters.Remove("PrefixMatch")
303+
$hasRenameTo = $PSBoundParameters.Remove("RenameTo")
299304
for($i = 0; $i -lt $ContainersList.length; $i++){
300305

301306
$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.ItemPathBasedRestoreCriteria]::new()
@@ -311,6 +316,19 @@
311316
}
312317
$restoreCriteria.SubItemPathPrefix = $pathPrefix
313318
}
319+
Write-Debug "renameContainersEnabled: $manifest.renameContainersEnabled"
320+
Write-Debug "hasRenameTo: $hasRenameTo"
321+
if($manifest.renameContainersEnabled -eq $true -and $hasRenameTo){
322+
Write-Debug "renameToValue: $($RenameTo[$ContainersList[$i]])"
323+
$renameToValue = $RenameTo[$ContainersList[$i]]
324+
if($renameToValue -ne $null -and ($renameToValue -is [Array])){
325+
throw "value for RenameTo must be a string for each container"
326+
}
327+
$restoreCriteria.RenameTo = $renameToValue
328+
}
329+
elseif( ($manifest.renameContainersEnabled -ne $true) -and ($hasRenameTo)){
330+
throw "DatasourceType $DatasourceType does not support renaming containers"
331+
}
314332

315333
# adding a criteria for each container given
316334
$restoreCriteriaList += ($restoreCriteria)

src/DataProtection/DataProtection.Autorest/custom/Enums/Enums.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public enum DatasourceTypes
88
AzureDisk = 0,
99
AzureBlob,
1010
AzureDatabaseForPostgreSQL,
11+
AzureDataLakeStorage,
1112
AzureKubernetesService,
1213
AzureDatabaseForPGFlexServer,
1314
AzureDatabaseForMySQL

src/DataProtection/DataProtection.Autorest/custom/manifests/AzureBlob.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"friendlyNameRequired": false,
2323
"customFriendlyNameAllowed": false,
2424
"supportSecretStoreAuthentication": false,
25-
"supportCrossRegionRestore": false,
25+
"supportCrossRegionRestore": true,
26+
"renameContainersEnabled": true,
2627
"policySettings": {
2728
"supportedRetentionTags": [ "Weekly", "Monthly", "Yearly" ],
2829
"supportedDatastoreTypes": [ "OperationalStore", "VaultStore" ],
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"datasourcePermissions": [ "Storage Account Backup Contributor" ],
3+
"datasourceRGPermissions": [],
4+
"snapshotRGPermissions": [],
5+
"keyVaultPermissions": [],
6+
"dataSourceOverSnapshotRGPermissions": [],
7+
"supportRestoreGrantPermission": false,
8+
"datasourcePermissionsForRestore": [],
9+
"storageAccountPermissionsForRestore": [],
10+
"isProxyResource": false,
11+
"enableDataSourceSetInfo": false,
12+
"resourceType": "Microsoft.Storage/storageAccounts",
13+
"parentResourceType": "Microsoft.Storage/storageAccounts",
14+
"datasourceType": "Microsoft.Storage/storageAccounts/adlsBlobServices",
15+
"allowedRestoreModes": [ "RecoveryPointBased" ],
16+
"allowedRestoreTargetTypes": [ "AlternateLocation" ],
17+
"itemLevelRecoveyEnabled": true,
18+
"fileNamePrefixDisabled": false,
19+
"addBackupDatasourceParametersList": true,
20+
"backupConfigurationRequired": false,
21+
"addDataStoreParametersList": false,
22+
"friendlyNameRequired": false,
23+
"customFriendlyNameAllowed": false,
24+
"supportSecretStoreAuthentication": false,
25+
"supportCrossRegionRestore": true,
26+
"renameContainersEnabled": true,
27+
"policySettings": {
28+
"supportedRetentionTags": [ "Weekly", "Monthly", "Yearly" ],
29+
"supportedDatastoreTypes": [ "VaultStore" ],
30+
"disableAddRetentionRule": false,
31+
"disableCustomRetentionTag": false,
32+
"backupScheduleSupported": true,
33+
"supportedBackupFrequency": [ "Daily", "Weekly" ],
34+
"defaultPolicy": {
35+
"policyRules": [
36+
{
37+
"backupParameters": {
38+
"backupType": "Discrete",
39+
"objectType": "AzureBackupParams"
40+
},
41+
"trigger": {
42+
"schedule": {
43+
"repeatingTimeIntervals": [
44+
"R/2023-03-26T13:00:00+00:00/P1W"
45+
],
46+
"timeZone": "UTC"
47+
},
48+
"taggingCriteria": [
49+
{
50+
"tagInfo": {
51+
"tagName": "Default",
52+
"id": "Default_"
53+
},
54+
"taggingPriority": 99,
55+
"isDefault": true
56+
}
57+
],
58+
"objectType": "ScheduleBasedTriggerContext"
59+
},
60+
"dataStore": {
61+
"dataStoreType": "VaultStore",
62+
"objectType": "DataStoreInfoBase"
63+
},
64+
"name": "BackupWeekly",
65+
"objectType": "AzureBackupRule"
66+
},
67+
{
68+
"lifecycles": [
69+
{
70+
"deleteAfter": {
71+
"objectType": "AbsoluteDeleteOption",
72+
"duration": "P7D"
73+
},
74+
"sourceDataStore": {
75+
"dataStoreType": "VaultStore",
76+
"objectType": "DataStoreInfoBase"
77+
}
78+
}
79+
],
80+
"isDefault": true,
81+
"name": "Default",
82+
"objectType": "AzureRetentionRule"
83+
}
84+
],
85+
"name": "AdlsBlobPolicy1",
86+
"datasourceTypes": [
87+
"Microsoft.Storage/storageAccounts/adlsBlobServices"
88+
],
89+
"objectType": "BackupPolicy"
90+
}
91+
}
92+
}

src/DataProtection/DataProtection.Autorest/custom/manifests/DatasourceTypesInfo.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"serviceDatasourceType": "Microsoft.Storage/storageAccounts/blobServices",
1313
"clientDatasourceType": "AzureBlob"
1414
},
15+
{
16+
"serviceDatasourceType": "Microsoft.Storage/storageAccounts/adlsBlobServices",
17+
"clientDatasourceType": "AzureDataLakeStorage"
18+
},
1519
{
1620
"serviceDatasourceType": "Microsoft.ContainerService/managedClusters",
1721
"clientDatasourceType": "AzureKubernetesService"

src/DataProtection/DataProtection.Autorest/docs/Initialize-AzDataProtectionBackupInstance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The fifth command initializes the backup instance.ype AzureDatabaseForMySQL to i
115115

116116
### -BackupConfiguration
117117
Backup configuration for backup.
118-
Use this parameter to configure protection for AzureKubernetesService,AzureBlob.
118+
Use this parameter to configure protection for AzureKubernetesService, AzureBlob and AzureDataLakeStorage.
119119
To construct, see NOTES section for BACKUPCONFIGURATION properties and create a hash table.
120120

121121
```yaml
@@ -191,7 +191,7 @@ Accept wildcard characters: False
191191
```
192192
193193
### -PolicyId
194-
Policy Id to be assiciated to Datasource
194+
Policy Id to be associated to Datasource
195195
196196
```yaml
197197
Type: System.String
@@ -238,7 +238,7 @@ Accept wildcard characters: False
238238
```
239239
240240
### -SnapshotResourceGroupId
241-
Sanpshot Resource Group
241+
Snapshot Resource Group
242242
243243
```yaml
244244
Type: System.String

src/DataProtection/DataProtection.Autorest/docs/Initialize-AzDataProtectionRestoreRequest.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Initialize-AzDataProtectionRestoreRequest -DatasourceType <DatasourceTypes> -Res
2727
Initialize-AzDataProtectionRestoreRequest -DatasourceType <DatasourceTypes> -ItemLevelRecovery
2828
-RestoreLocation <String> -RestoreType <RestoreTargetType> -SourceDataStore <DataStoreType>
2929
-TargetResourceId <String> [-ContainersList <String[]>] [-PrefixMatch <Hashtable>] [-RecoveryPoint <String>]
30-
[-RestoreConfiguration <PSObject>] [-UserAssignedIdentityArmId <String>]
30+
[-RenameTo <Hashtable>] [-RestoreConfiguration <PSObject>] [-UserAssignedIdentityArmId <String>]
3131
[-UseSystemAssignedIdentity <Boolean?>] [<CommonParameters>]
3232
```
3333

@@ -221,7 +221,7 @@ The restore request object is then used to trigger the restore operation.
221221
## PARAMETERS
222222

223223
### -BackupInstance
224-
Backup Instance object to trigger original localtion restore.
224+
Backup Instance object to trigger original location restore.
225225
To construct, see NOTES section for BACKUPINSTANCE properties and create a hash table.
226226

227227
```yaml
@@ -391,6 +391,22 @@ Accept pipeline input: False
391391
Accept wildcard characters: False
392392
```
393393
394+
### -RenameTo
395+
Use this parameter to rename container(s) for alternate location ILR.
396+
Input for this parameter is a hashtable where each key is the original container name and each value is the new name for the corresponding container.
397+
398+
```yaml
399+
Type: System.Collections.Hashtable
400+
Parameter Sets: AlternateLocationILR
401+
Aliases:
402+
403+
Required: False
404+
Position: Named
405+
Default value: None
406+
Accept pipeline input: False
407+
Accept wildcard characters: False
408+
```
409+
394410
### -RestoreConfiguration
395411
Restore configuration for restore.
396412
Use this parameter to restore with AzureKubernetesService.

0 commit comments

Comments
 (0)