forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate DataProtection from generation to main (Azure#24658)
* Move DataProtection to main * Update ChangeLog.md --------- Co-authored-by: NanxiangLiu <[email protected]>
- Loading branch information
1 parent
e220a68
commit 4b94eea
Showing
186 changed files
with
6,257 additions
and
1,248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
139 changes: 139 additions & 0 deletions
139
...Autorest/custom/Cmdlets/Platform/BackupInstance/Update-AzDataProtectionBackupInstance.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
|
||
|
||
function Update-AzDataProtectionBackupInstance | ||
{ | ||
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.IBackupInstanceResource')] | ||
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Description('Updates a given backup instance')] | ||
|
||
param( | ||
[Parameter(Mandatory=$false, HelpMessage='Subscription Id of the vault')] | ||
[System.String] | ||
${SubscriptionId}, | ||
|
||
[Parameter(Mandatory, HelpMessage='Resource Group of the backup vault')] | ||
[System.String] | ||
${ResourceGroupName}, | ||
|
||
[Parameter(Mandatory, HelpMessage='Name of the backup vault')] | ||
[System.String] | ||
${VaultName}, | ||
|
||
[Parameter(Mandatory, HelpMessage='Unique Name of protected backup instance')] | ||
[System.String] | ||
${BackupInstanceName}, | ||
|
||
[Parameter(Mandatory=$false, HelpMessage='Id of the Policy to be associated with the backup instance')] | ||
[System.String] | ||
${PolicyId}, | ||
|
||
[Parameter(Mandatory=$false, HelpMessage='List of containers to be backed up inside the VaultStore. Use this parameter for DatasourceType AzureBlob.')] | ||
[System.String[]] | ||
${VaultedBackupContainer}, | ||
|
||
[Parameter()] | ||
[Alias('AzureRMContext', 'AzureCredential')] | ||
[ValidateNotNull()] | ||
[System.Management.Automation.PSObject] | ||
# The credentials, account, tenant, and subscription used for communication with Azure. | ||
${DefaultProfile}, | ||
|
||
[Parameter(DontShow)] | ||
[System.Management.Automation.SwitchParameter] | ||
# Wait for .NET debugger to attach | ||
${Break}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[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.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
${HttpPipelinePrepend}, | ||
|
||
[Parameter(DontShow)] | ||
[System.Uri] | ||
# The URI for the proxy server to use | ||
${Proxy}, | ||
|
||
[Parameter()] | ||
[System.Management.Automation.SwitchParameter] | ||
# Run the command as a job | ||
${AsJob}, | ||
|
||
[Parameter()] | ||
[System.Management.Automation.SwitchParameter] | ||
# Run the command asynchronously | ||
${NoWait}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[System.Management.Automation.PSCredential] | ||
# Credentials for a proxy server to use for the remote call | ||
${ProxyCredential}, | ||
|
||
[Parameter(DontShow)] | ||
[System.Management.Automation.SwitchParameter] | ||
# Use the default credentials for the proxy | ||
${ProxyUseDefaultCredentials} | ||
) | ||
|
||
process | ||
{ | ||
$hasPolicyId = $PSBoundParameters.Remove("PolicyId") | ||
$hasVaultedBackupContainer = $PSBoundParameters.Remove("VaultedBackupContainer") | ||
|
||
$instance = Az.DataProtection\Get-AzDataProtectionBackupInstance @PSBoundParameters | ||
|
||
if($hasPolicyId){ | ||
$instance.Property.PolicyInfo.PolicyId = $PolicyId | ||
} | ||
|
||
$DatasourceType = GetClientDatasourceType -ServiceDatasourceType $instance.Property.DataSourceInfo.Type | ||
# $manifest = LoadManifest -DatasourceType $DatasourceType.ToString() | ||
|
||
if($hasVaultedBackupContainer){ | ||
|
||
if($DatasourceType -ne "AzureBlob"){ | ||
$err = "Parameter VaultedBackupContainer isn't supported for given Datasource" | ||
throw $err | ||
} | ||
|
||
# exclude containers which start with $ except $web, $root | ||
$unsupportedContainers = $VaultedBackupContainer | Where-Object { $_ -like '$*' -and $_ -ne "`$root" -and $_ -ne "`$web"} | ||
if($unsupportedContainers.Count -gt 0){ | ||
$message = "Following containers are not allowed for configure protection with AzureBlob - $unsupportedContainers. Please remove them and try again." | ||
throw $message | ||
} | ||
|
||
$datasourceParam = $instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList | ||
|
||
if($datasourceParam -ne $null -and $datasourceParam[0].ObjectType -eq "BlobBackupDatasourceParameters"){ | ||
$instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList[0].ContainersList = $VaultedBackupContainer | ||
} | ||
elseif($datasourceParam -eq $null){ | ||
$backupConfiguration = [Microsoft.Azure.PowerShell.Cmdlets.DataProtection.Models.Api20231201.BlobBackupDatasourceParameters]::new() | ||
$backupConfiguration.ObjectType = "BlobBackupDatasourceParameters" | ||
$backupConfiguration.ContainersList = $VaultedBackupContainer | ||
|
||
$instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList += @($backupConfiguration) | ||
} | ||
else{ | ||
$err = "instance.Property.PolicyInfo.PolicyParameter.BackupDatasourceParametersList is not in proper format." | ||
throw $err | ||
} | ||
} | ||
|
||
# deep validate for update-BI | ||
$instance.Property.ValidationType = "DeepValidation" | ||
|
||
$null = $PSBoundParameters.Remove("BackupInstanceName") | ||
$null = $PSBoundParameters.Add("Name", $instance.Name) | ||
$null = $PSBoundParameters.Add("Parameter", $instance) | ||
Az.DataProtection.Internal\New-AzDataProtectionBackupInstance @PSBoundParameters | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.