Skip to content

Commit 4b94eea

Browse files
Migrate DataProtection from generation to main (#24658)
* Move DataProtection to main * Update ChangeLog.md --------- Co-authored-by: NanxiangLiu <33285578+Nickcandy@users.noreply.github.com>
1 parent e220a68 commit 4b94eea

File tree

186 files changed

+6257
-1248
lines changed

Some content is hidden

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

186 files changed

+6257
-1248
lines changed

src/DataProtection/DataProtection.Autorest/Az.DataProtection.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
DotNetFrameworkVersion = '4.7.2'
1212
RequiredAssemblies = './bin/Az.DataProtection.private.dll'
1313
FormatsToProcess = './Az.DataProtection.format.ps1xml'
14-
FunctionsToExport = 'Backup-AzDataProtectionBackupInstanceAdhoc', 'Edit-AzDataProtectionPolicyRetentionRuleClientObject', 'Edit-AzDataProtectionPolicyTagClientObject', 'Edit-AzDataProtectionPolicyTriggerClientObject', 'Find-AzDataProtectionRestorableTimeRange', 'Get-AzDataProtectionBackupInstance', 'Get-AzDataProtectionBackupPolicy', 'Get-AzDataProtectionBackupVault', 'Get-AzDataProtectionJob', 'Get-AzDataProtectionOperation', 'Get-AzDataProtectionOperationStatus', 'Get-AzDataProtectionPolicyTemplate', 'Get-AzDataProtectionRecoveryPoint', 'Get-AzDataProtectionResourceGuard', 'Get-AzDataProtectionResourceGuardMapping', 'Get-AzDataProtectionSoftDeletedBackupInstance', 'Initialize-AzDataProtectionBackupInstance', 'Initialize-AzDataProtectionRestoreRequest', 'New-AzDataProtectionBackupConfigurationClientObject', 'New-AzDataProtectionBackupInstance', 'New-AzDataProtectionBackupPolicy', 'New-AzDataProtectionBackupVault', 'New-AzDataProtectionBackupVaultStorageSettingObject', 'New-AzDataProtectionPolicyTagCriteriaClientObject', 'New-AzDataProtectionPolicyTriggerScheduleClientObject', 'New-AzDataProtectionResourceGuard', 'New-AzDataProtectionRestoreConfigurationClientObject', 'New-AzDataProtectionRetentionLifeCycleClientObject', 'Remove-AzDataProtectionBackupInstance', 'Remove-AzDataProtectionBackupPolicy', 'Remove-AzDataProtectionBackupVault', 'Remove-AzDataProtectionResourceGuard', 'Remove-AzDataProtectionResourceGuardMapping', 'Resume-AzDataProtectionBackupInstanceProtection', 'Search-AzDataProtectionBackupInstanceInAzGraph', 'Search-AzDataProtectionBackupVaultInAzGraph', 'Search-AzDataProtectionJobInAzGraph', 'Set-AzDataProtectionMSIPermission', 'Set-AzDataProtectionResourceGuardMapping', 'Start-AzDataProtectionBackupInstanceRestore', 'Stop-AzDataProtectionBackupInstanceProtection', 'Suspend-AzDataProtectionBackupInstanceBackup', 'Sync-AzDataProtectionBackupInstance', 'Test-AzDataProtectionBackupInstanceReadiness', 'Test-AzDataProtectionBackupInstanceRestore', 'Undo-AzDataProtectionBackupInstanceDeletion', 'Unlock-AzDataProtectionResourceGuardOperation', 'Update-AzDataProtectionBackupInstanceAssociatedPolicy', 'Update-AzDataProtectionBackupVault', 'Update-AzDataProtectionResourceGuard', '*'
14+
FunctionsToExport = 'Backup-AzDataProtectionBackupInstanceAdhoc', 'Edit-AzDataProtectionPolicyRetentionRuleClientObject', 'Edit-AzDataProtectionPolicyTagClientObject', 'Edit-AzDataProtectionPolicyTriggerClientObject', 'Find-AzDataProtectionRestorableTimeRange', 'Get-AzDataProtectionBackupInstance', 'Get-AzDataProtectionBackupPolicy', 'Get-AzDataProtectionBackupVault', 'Get-AzDataProtectionJob', 'Get-AzDataProtectionOperation', 'Get-AzDataProtectionOperationStatus', 'Get-AzDataProtectionPolicyTemplate', 'Get-AzDataProtectionRecoveryPoint', 'Get-AzDataProtectionResourceGuard', 'Get-AzDataProtectionResourceGuardMapping', 'Get-AzDataProtectionSoftDeletedBackupInstance', 'Initialize-AzDataProtectionBackupInstance', 'Initialize-AzDataProtectionRestoreRequest', 'New-AzDataProtectionBackupConfigurationClientObject', 'New-AzDataProtectionBackupInstance', 'New-AzDataProtectionBackupPolicy', 'New-AzDataProtectionBackupVault', 'New-AzDataProtectionBackupVaultStorageSettingObject', 'New-AzDataProtectionPolicyTagCriteriaClientObject', 'New-AzDataProtectionPolicyTriggerScheduleClientObject', 'New-AzDataProtectionResourceGuard', 'New-AzDataProtectionRestoreConfigurationClientObject', 'New-AzDataProtectionRetentionLifeCycleClientObject', 'Remove-AzDataProtectionBackupInstance', 'Remove-AzDataProtectionBackupPolicy', 'Remove-AzDataProtectionBackupVault', 'Remove-AzDataProtectionResourceGuard', 'Remove-AzDataProtectionResourceGuardMapping', 'Resume-AzDataProtectionBackupInstanceProtection', 'Search-AzDataProtectionBackupInstanceInAzGraph', 'Search-AzDataProtectionBackupVaultInAzGraph', 'Search-AzDataProtectionJobInAzGraph', 'Set-AzDataProtectionMSIPermission', 'Set-AzDataProtectionResourceGuardMapping', 'Start-AzDataProtectionBackupInstanceRestore', 'Stop-AzDataProtectionBackupInstanceProtection', 'Suspend-AzDataProtectionBackupInstanceBackup', 'Sync-AzDataProtectionBackupInstance', 'Test-AzDataProtectionBackupInstanceReadiness', 'Test-AzDataProtectionBackupInstanceRestore', 'Undo-AzDataProtectionBackupInstanceDeletion', 'Unlock-AzDataProtectionResourceGuardOperation', 'Update-AzDataProtectionBackupInstance', 'Update-AzDataProtectionBackupInstanceAssociatedPolicy', 'Update-AzDataProtectionBackupVault', 'Update-AzDataProtectionResourceGuard', '*'
1515
AliasesToExport = '*'
1616
PrivateData = @{
1717
PSData = @{

src/DataProtection/DataProtection.Autorest/Az.DataProtection.psm1

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,41 @@
4747

4848
# Ask for the shared functionality table
4949
$VTable = Register-AzModule
50-
50+
5151
# Tweaks the pipeline on module load
5252
$instance.OnModuleLoad = $VTable.OnModuleLoad
5353

5454
# Following two delegates are added for telemetry
5555
$instance.GetTelemetryId = $VTable.GetTelemetryId
5656
$instance.Telemetry = $VTable.Telemetry
57-
57+
58+
# Delegate to sanitize the output object
59+
$instance.SanitizeOutput = $VTable.SanitizerHandler
60+
61+
# Delegate to get the telemetry info
62+
$instance.GetTelemetryInfo = $VTable.GetTelemetryInfo
5863

5964
# Tweaks the pipeline per call
6065
$instance.OnNewRequest = $VTable.OnNewRequest
61-
66+
6267
# Gets shared parameter values
6368
$instance.GetParameterValue = $VTable.GetParameterValue
64-
69+
6570
# Allows shared module to listen to events from this module
6671
$instance.EventListener = $VTable.EventListener
67-
72+
6873
# Gets shared argument completers
6974
$instance.ArgumentCompleter = $VTable.ArgumentCompleter
70-
75+
7176
# The name of the currently selected Azure profile
7277
$instance.ProfileName = $VTable.ProfileName
7378

74-
7579
# Load the custom module
7680
$customModulePath = Join-Path $PSScriptRoot './custom/Az.DataProtection.custom.psm1'
7781
if(Test-Path $customModulePath) {
7882
$null = Import-Module -Name $customModulePath
7983
}
80-
84+
8185
# Export nothing to clear implicit exports
8286
Export-ModuleMember
8387

@@ -97,12 +101,12 @@
97101
# Load the last folder if no profile is selected
98102
$profileDirectory = $directories | Select-Object -Last 1
99103
}
100-
104+
101105
if($profileDirectory) {
102106
Write-Information "Loaded Azure profile '$($profileDirectory.Name)' for module '$($instance.Name)'"
103107
$exportsPath = $profileDirectory.FullName
104108
}
105-
109+
106110
if($exportsPath) {
107111
Get-ChildItem -Path $exportsPath -Recurse -Include '*.ps1' -File | ForEach-Object { . $_.FullName }
108112
$cmdletNames = Get-ScriptCmdlet -ScriptFolder $exportsPath

src/DataProtection/DataProtection.Autorest/custom/Cmdlets/Backupcenter/Search-AzDataProtectionBackupVaultInAzGraph.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[Parameter(Mandatory, HelpMessage='Subscription of Vault')]
99
[Alias('SubscriptionId')]
1010
[System.String[]]
11-
${Subscription},
11+
${Subscription}, # TODO: add alias to all ARG command params
1212

1313
[Parameter(Mandatory=$false, HelpMessage='Resource Group of Vault')]
1414
[Alias('ResourceGroupName')]

src/DataProtection/DataProtection.Autorest/custom/Cmdlets/Common/Initialize-AzDataProtectionBackupInstance.ps1 renamed to 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
@@ -43,7 +43,7 @@ function Initialize-AzDataProtectionBackupInstance {
4343
[System.String]
4444
${FriendlyName},
4545

46-
[Parameter(Mandatory=$false, HelpMessage='Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService.')]
46+
[Parameter(Mandatory=$false, HelpMessage='Backup configuration for backup. Use this parameter to configure protection for AzureKubernetesService,AzureBlob.')]
4747
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.IBackupDatasourceParameters]
4848
${BackupConfiguration}
4949
)
@@ -118,7 +118,7 @@ function Initialize-AzDataProtectionBackupInstance {
118118
else{
119119
$errormsg = "Please ensure that secret store based authentication is supported for given data source"
120120
throw $errormsg
121-
}
121+
}
122122
}
123123

124124
$backupInstanceResource = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.BackupInstanceResource]::new()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
2+
3+
function Update-AzDataProtectionBackupInstance
4+
{
5+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.IBackupInstanceResource')]
6+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)]
7+
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Updates a given backup instance')]
8+
9+
param(
10+
[Parameter(Mandatory=$false, HelpMessage='Subscription Id of the vault')]
11+
[System.String]
12+
${SubscriptionId},
13+
14+
[Parameter(Mandatory, HelpMessage='Resource Group of the backup vault')]
15+
[System.String]
16+
${ResourceGroupName},
17+
18+
[Parameter(Mandatory, HelpMessage='Name of the backup vault')]
19+
[System.String]
20+
${VaultName},
21+
22+
[Parameter(Mandatory, HelpMessage='Unique Name of protected backup instance')]
23+
[System.String]
24+
${BackupInstanceName},
25+
26+
[Parameter(Mandatory=$false, HelpMessage='Id of the Policy to be associated with the backup instance')]
27+
[System.String]
28+
${PolicyId},
29+
30+
[Parameter(Mandatory=$false, HelpMessage='List of containers to be backed up inside the VaultStore. Use this parameter for DatasourceType AzureBlob.')]
31+
[System.String[]]
32+
${VaultedBackupContainer},
33+
34+
[Parameter()]
35+
[Alias('AzureRMContext', 'AzureCredential')]
36+
[ValidateNotNull()]
37+
[System.Management.Automation.PSObject]
38+
# The credentials, account, tenant, and subscription used for communication with Azure.
39+
${DefaultProfile},
40+
41+
[Parameter(DontShow)]
42+
[System.Management.Automation.SwitchParameter]
43+
# Wait for .NET debugger to attach
44+
${Break},
45+
46+
[Parameter(DontShow)]
47+
[ValidateNotNull()]
48+
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SendAsyncStep[]]
49+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
50+
${HttpPipelineAppend},
51+
52+
[Parameter(DontShow)]
53+
[ValidateNotNull()]
54+
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SendAsyncStep[]]
55+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
56+
${HttpPipelinePrepend},
57+
58+
[Parameter(DontShow)]
59+
[System.Uri]
60+
# The URI for the proxy server to use
61+
${Proxy},
62+
63+
[Parameter()]
64+
[System.Management.Automation.SwitchParameter]
65+
# Run the command as a job
66+
${AsJob},
67+
68+
[Parameter()]
69+
[System.Management.Automation.SwitchParameter]
70+
# Run the command asynchronously
71+
${NoWait},
72+
73+
[Parameter(DontShow)]
74+
[ValidateNotNull()]
75+
[System.Management.Automation.PSCredential]
76+
# Credentials for a proxy server to use for the remote call
77+
${ProxyCredential},
78+
79+
[Parameter(DontShow)]
80+
[System.Management.Automation.SwitchParameter]
81+
# Use the default credentials for the proxy
82+
${ProxyUseDefaultCredentials}
83+
)
84+
85+
process
86+
{
87+
$hasPolicyId = $PSBoundParameters.Remove("PolicyId")
88+
$hasVaultedBackupContainer = $PSBoundParameters.Remove("VaultedBackupContainer")
89+
90+
$instance = Az.DataProtection\Get-AzDataProtectionBackupInstance @PSBoundParameters
91+
92+
if($hasPolicyId){
93+
$instance.Property.PolicyInfo.PolicyId = $PolicyId
94+
}
95+
96+
$DatasourceType = GetClientDatasourceType -ServiceDatasourceType $instance.Property.DataSourceInfo.Type
97+
# $manifest = LoadManifest -DatasourceType $DatasourceType.ToString()
98+
99+
if($hasVaultedBackupContainer){
100+
101+
if($DatasourceType -ne "AzureBlob"){
102+
$err = "Parameter VaultedBackupContainer isn't supported for given Datasource"
103+
throw $err
104+
}
105+
106+
# exclude containers which start with $ except $web, $root
107+
$unsupportedContainers = $VaultedBackupContainer | Where-Object { $_ -like '$*' -and $_ -ne "`$root" -and $_ -ne "`$web"}
108+
if($unsupportedContainers.Count -gt 0){
109+
$message = "Following containers are not allowed for configure protection with AzureBlob - $unsupportedContainers. Please remove them and try again."
110+
throw $message
111+
}
112+
113+
$datasourceParam = $instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList
114+
115+
if($datasourceParam -ne $null -and $datasourceParam[0].ObjectType -eq "BlobBackupDatasourceParameters"){
116+
$instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList[0].ContainersList = $VaultedBackupContainer
117+
}
118+
elseif($datasourceParam -eq $null){
119+
$backupConfiguration = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.BlobBackupDatasourceParameters]::new()
120+
$backupConfiguration.ObjectType = "BlobBackupDatasourceParameters"
121+
$backupConfiguration.ContainersList = $VaultedBackupContainer
122+
123+
$instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList += @($backupConfiguration)
124+
}
125+
else{
126+
$err = "instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList is not in proper format."
127+
throw $err
128+
}
129+
}
130+
131+
# deep validate for update-BI
132+
$instance.Property.ValidationType = "DeepValidation"
133+
134+
$null = $PSBoundParameters.Remove("BackupInstanceName")
135+
$null = $PSBoundParameters.Add("Name", $instance.Name)
136+
$null = $PSBoundParameters.Add("Parameter", $instance)
137+
Az.DataProtection.Internal\New-AzDataProtectionBackupInstance @PSBoundParameters
138+
}
139+
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,17 @@
102102
[Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Container names for Item Level Recovery.')]
103103
[System.String[]]
104104
${ContainersList},
105+
106+
[Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Use this parameter to filter block blobs by prefix in a container for alternate location ILR. When you specify a prefix, only blobs matching that prefix in the container will be restored. Input for this parameter is a hashtable where each key is a container name and each value is an array of string prefixes for that container.')]
107+
[Hashtable]
108+
${PrefixMatch},
105109

106-
[Parameter(ParameterSetName="OriginalLocationILR", Mandatory=$false, HelpMessage='Minimum matching value for Item Level Recovery.')]
110+
[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.')]
107111
# [Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Minimum matching value for Item Level Recovery.')]
108112
[System.String[]]
109113
${FromPrefixPattern},
110114

111-
[Parameter(ParameterSetName="OriginalLocationILR", Mandatory=$false, HelpMessage='Maximum matching value for Item Level Recovery.')]
115+
[Parameter(ParameterSetName="OriginalLocationILR", Mandatory=$false, HelpMessage='Specify the blob restore end range for PITR. You can use this option to specify the ending 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.')]
112116
# [Parameter(ParameterSetName="AlternateLocationILR", Mandatory=$false, HelpMessage='Maximum matching value for Item Level Recovery.')]
113117
[System.String[]]
114118
${ToPrefixPattern},
@@ -257,6 +261,7 @@
257261
if($DatasourceType -ne "AzureKubernetesService"){ # TODO: remove Datasource dependency
258262

259263
if(($RecoveryPoint -ne $null) -and ($RecoveryPoint -ne "") -and $ContainersList.length -gt 0){
264+
$hasPrefixMatch = $PSBoundParameters.Remove("PrefixMatch")
260265
for($i = 0; $i -lt $ContainersList.length; $i++){
261266

262267
$restoreCriteria = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.ItemPathBasedRestoreCriteria]::new()
@@ -265,6 +270,14 @@
265270
$restoreCriteria.ItemPath = $ContainersList[$i]
266271
$restoreCriteria.IsPathRelativeToBackupItem = $true
267272

273+
if($hasPrefixMatch){
274+
$pathPrefix = $PrefixMatch[$ContainersList[$i]]
275+
if($pathPrefix -ne $null -and !($pathPrefix -is [Array])){
276+
throw "values for PrefixMatch must be string array for each container"
277+
}
278+
$restoreCriteria.SubItemPathPrefix = $pathPrefix
279+
}
280+
268281
# adding a criteria for each container given
269282
$restoreCriteriaList += ($restoreCriteria)
270283
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This object can now be used to configure backup for the given disk.
1919

2020
### Example 2: Initialize Backup instance object for AzureKubernetesService
2121
```powershell
22-
$policy = Get-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -VaultName "vaultName" -ResourceGroupName "resourceGroupName" | where {$_.Name -eq "policyName"}
22+
$policy = Get-AzDataProtectionBackupPolicy -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -VaultName "vaultName" -ResourceGroupName "resourceGroupName" | Where-Object {$_.Name -eq "policyName"}
2323
$sourceClusterId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName/providers/Microsoft.ContainerService/managedClusters/aks-cluster"
2424
$snapshotResourceGroupId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName"
2525
$backupConfig = New-AzDataProtectionBackupConfigurationClientObject -SnapshotVolume $true -IncludeClusterScopeResource $true -DatasourceType AzureKubernetesService -LabelSelector "x=y","foo=bar"

0 commit comments

Comments
 (0)