Skip to content

Commit 90552da

Browse files
author
ianna1-admin
committed
functional changes for adls & blob manifest & unit tests
1 parent c0df399 commit 90552da

File tree

10 files changed

+621
-72
lines changed

10 files changed

+621
-72
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
[System.String]
4141
${FriendlyName},
4242

43-
[Parameter(Mandatory=$false, HelpMessage='Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService,AzureBlob.')]
43+
[Parameter(Mandatory=$false, HelpMessage='Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService, AzureBlob, AzureDataLakeStorage.')]
4444
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.IBackupDatasourceParameters]
4545
${BackupConfiguration},
4646

@@ -185,14 +185,6 @@
185185
throw $errormsg
186186
}
187187

188-
if($manifest.enableDataSourceSetInfo -eq $true)
189-
{
190-
$backupInstanceResource.Property.DataSourceSetInfo = GetDatasourceInfo -ResourceId $DatasourceId -ResourceLocation $DatasourceLocation -DatasourceType $DatasourceType
191-
$tmpVar = $backupInstance.DataSourceSetInfo = GetDatasourceSetInfo -DatasourceInfo $backupInstance.DataSourceInfo -DatasourceType $DatasourceType
192-
193-
$backupInstanceResource.Property.DataSourceSetInfo.ObjectType = $tmpVar.ObjectType
194-
}
195-
196188
return $backupInstanceResource
197189
}
198190
}

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

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

138177
$dataSourceParam
139178
}

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

Lines changed: 12 additions & 6 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,26 +135,32 @@ 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

150150
$datasourceParam = $instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList
151151

152-
if($datasourceParam -ne $null -and $datasourceParam[0].ObjectType -eq "BlobBackupDatasourceParameters"){
152+
if($datasourceParam -ne $null -and $datasourceParam[0].ObjectType -eq "BlobBackupDatasourceParameters" -or $datasourceParam[0].ObjectType -eq "AdlsBlobBackupDatasourceParameters"){
153153
$instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList[0].ContainersList = $VaultedBackupContainer
154154
}
155155
elseif($datasourceParam -eq $null){
156-
$backupConfiguration = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.BlobBackupDatasourceParameters]::new()
157-
$backupConfiguration.ObjectType = "BlobBackupDatasourceParameters"
156+
if ($DatasourceType -eq "AzureBlob"){
157+
$backupConfiguration = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.BlobBackupDatasourceParameters]::new()
158+
$backupConfiguration.ObjectType = "BlobBackupDatasourceParameters"
159+
}
160+
elseif ($DatasourceType -eq "AzureDataLakeStorage"){
161+
$backupConfiguration = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20250701.AdlsBlobBackupDatasourceParameters]::new()
162+
$backupConfiguration.ObjectType = "AdlsBlobBackupDatasourceParameters"
163+
}
158164
$backupConfiguration.ContainersList = $VaultedBackupContainer
159165

160166
$instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList += @($backupConfiguration)

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

Lines changed: 16 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()
@@ -312,6 +317,17 @@
312317
$restoreCriteria.SubItemPathPrefix = $pathPrefix
313318
}
314319

320+
if($manifest.renameContainersEnabled -eq $true -and $hasRenameTo){
321+
$renameToValue = $RenameTo[$ContainersList[$i]]
322+
if($renameToValue -ne $null -and ($renameToValue -is [Array])){
323+
throw "value for RenameTo must be a string for each container"
324+
}
325+
$restoreCriteria.RenameTo = $renameToValue
326+
}
327+
elseif( ($manifest.renameContainersEnabled -ne $true) -and ($hasRenameTo)){
328+
throw "DatasourceType $DatasourceType does not support renaming containers"
329+
}
330+
315331
# adding a criteria for each container given
316332
$restoreCriteriaList += ($restoreCriteria)
317333
}

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"snapshotRGPermissions": [],
55
"keyVaultPermissions": [],
66
"dataSourceOverSnapshotRGPermissions": [],
7-
"supportRestoreGrantPermission": false,
7+
"supportRestoreGrantPermission": true,
88
"datasourcePermissionsForRestore": [],
99
"storageAccountPermissionsForRestore": [],
10-
"isProxyResource": false,
11-
"enableDataSourceSetInfo": false,
10+
"isProxyResource": true,
11+
"enableDataSourceSetInfo": true,
1212
"resourceType": "Microsoft.Storage/storageAccounts",
1313
"parentResourceType": "Microsoft.Storage/storageAccounts",
1414
"datasourceType": "Microsoft.Storage/storageAccounts/blobServices",
@@ -23,6 +23,7 @@
2323
"customFriendlyNameAllowed": false,
2424
"supportSecretStoreAuthentication": false,
2525
"supportCrossRegionRestore": false,
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": true,
8+
"datasourcePermissionsForRestore": [],
9+
"storageAccountPermissionsForRestore": [],
10+
"isProxyResource": true,
11+
"enableDataSourceSetInfo": true,
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": false,
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"

0 commit comments

Comments
 (0)