Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Az.DataProtection] Added support for Cross region restore for Backup vaults #23818

Merged
merged 5 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.DataProtection.private.dll'
FormatsToProcess = './Az.DataProtection.format.ps1xml'
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-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', '*'
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', '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Expand Down
38 changes: 31 additions & 7 deletions src/DataProtection/DataProtection.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ This file contains the configuration for generating My API from the OpenAPI spec

``` yaml
# it's the same options as command line options, just drop the double-dash!
commit: acf24167b5174d88f36302e243c883f2e63eec52
commit: c0e7b1360c19187fde2497251f784aa82641aa95
require:
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
- $(repo)/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/dataprotection.json
- $(repo)/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-11-01/dataprotection.json
title: DataProtection
# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option
use-extension:
Expand Down Expand Up @@ -236,6 +236,10 @@ directive:
verb: Start
subject: ExportJob
remove: true
- where:
verb: Start
subject: .*Restore$
hide: true
- where:
verb: Get
subject: OperationResultPatch
Expand Down Expand Up @@ -306,6 +310,23 @@ directive:
subject: BackupInstanceRestore
variant: ^Validate1$|^ValidateExpanded1$|^ValidateViaIdentity1$|^ValidateViaIdentityExpanded1$
hide: true
- where:
verb: Test
subject: BackupInstanceCrossRegionRestore
hide: true
- where:
subject: FetchCrossRegionRestoreJob
set:
subject: CrossRegionRestoreJob
- where:
subject: CrossRegionRestoreJob
variant: ^Get.*
set:
subject: CrossRegionRestoreJobDetail
- where:
verb: Get
subject: ^Job$|^CrossRegionRestoreJob.*|FetchSecondaryRecoveryPoint
hide: true
- where:
property-name: AzureMonitorAlertSettingAlertsForAllJobFailure
set:
Expand Down Expand Up @@ -363,6 +384,8 @@ directive:
- IdentityType
- no-inline:
- BackupInstance
- CrossRegionRestoreDetails
- CrossRegionRestoreRequestObject
- DeletionInfo
- InnerError
- ItemLevelRestoreTargetInfo
Expand All @@ -374,19 +397,20 @@ directive:
- SecretStoreResource
- SystemData
- UserFacingError
- ValidateRestoreRequestObject
- ValidateRestoreRequestObject
- ValidateCrossRegionRestoreRequestObject
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.IBaseBackupPolicy Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.IBaseBackupPolicy Property');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.IBaseBackupPolicy Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.IBaseBackupPolicy Property');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.ITriggerContext Trigger', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.ITriggerContext Trigger');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.ITriggerContext Trigger', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.ITriggerContext Trigger');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.IBackupParameters BackupParameter', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.IBackupParameters BackupParameter');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.IBackupParameters BackupParameter', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.IBackupParameters BackupParameter');
- from: source-file-csharp
where: $
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.IAzureBackupRecoveryPoint Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.IAzureBackupRecoveryPoint Property');
transform: $ = $.replace('internal Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.IAzureBackupRecoveryPoint Property', 'public Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.IAzureBackupRecoveryPoint Property');
```

## Alternate settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "backupVaults/backupInstances/recoveryPoints",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "backupVaults/backupInstances",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"resourceType": "backupVaults/backupJobs",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
"commands": [
{
"name": "Get-AzDataProtectionJob",
"description": "Gets a job with id in a backup vault",
"description": "Gets or lists jobs in a backup vault",
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}",
"help": {
"learnMore": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "backupVaults/backupPolicies",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "backupVaults/backupResourceGuardProxies",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "backupVaults/deletedBackupInstances",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "backupVaults",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "locations/operationStatus",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "resourceGuards",
"apiVersion": "2023-05-01",
"apiVersion": "2023-11-01",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.dataprotection"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,53 @@

[Parameter(Mandatory=$false, HelpMessage='Protection Status of the item')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Support.ProtectionStatus[]]
${ProtectionStatus}
${ProtectionStatus},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process
Expand All @@ -49,13 +95,14 @@
$null = $PSBoundParameters.Add("Subscription", $Subscription)
$null = $PSBoundParameters.Add("query", $query)
$null = $PSBoundParameters.Add("First", 1000)
$null = $PSBoundParameters.Remove("HttpPipelinePrepend")

$argInstanceResponse = Az.ResourceGraph\Search-AzGraph @PSBoundParameters
$backupInstances = @()
foreach($argResponse in $argInstanceResponse)
{
$jsonStringResponse = $argResponse | ConvertTo-Json -Depth 100
$backupInstances += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20230501.BackupInstanceResource]::FromJsonString($jsonStringResponse)
$backupInstances += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.BackupInstanceResource]::FromJsonString($jsonStringResponse)
}
return $backupInstances
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
function Search-AzDataProtectionBackupVaultInAzGraph
{
[OutputType('PSObject')]
[CmdletBinding(PositionalBinding=$false)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Searches for Backup vaults in Azure Resource Graph and retrieves the expected entries')]

param (
[Parameter(Mandatory, HelpMessage='Subscription of Vault')]
[System.String[]]
${Subscription},

[Parameter(Mandatory=$false, HelpMessage='Resource Group of Vault')]
[System.String[]]
${ResourceGroup},

[Parameter(Mandatory=$false, HelpMessage='Name of the vault')]
[System.String[]]
${Vault},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process
{
CheckResourceGraphModuleDependency

# $manifest = LoadManifest -DatasourceType $DatasourceType
$query = GetBackupVaultARGQuery

if($PSBoundParameters.ContainsKey("ResourceGroup")){ $query = AddFilterToQuery -Query $query -FilterKey "resourceGroup" -FilterValues $ResourceGroup }
if($PSBoundParameters.ContainsKey("Vault")){ $query = AddFilterToQuery -Query $query -FilterKey "name" -FilterValues $Vault }

foreach($param in @("Subscription", "ResourceGroup", "Vault"))
{
if($PSBoundParameters.ContainsKey($param))
{
$null = $PSBoundParameters.Remove($param)
}
}
$null = $PSBoundParameters.Add("Subscription", $Subscription)
$null = $PSBoundParameters.Add("query", $query)
$null = $PSBoundParameters.Add("First", 1000)
$null = $PSBoundParameters.Remove("HttpPipelinePrepend")

$argAllVaults = Az.ResourceGraph\Search-AzGraph @PSBoundParameters
$backupVaults = @()
foreach($argVault in $argAllVaults)
{
$jsonStringResponse = $argVault | ConvertTo-Json -Depth 100
$backupVaults += [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231101.BackupVaultResource]::FromJsonString($jsonStringResponse)
}
return $backupVaults
}
}
Loading