Skip to content

Commit

Permalink
Move ResourceMover to release-2021-03-02 (#14310)
Browse files Browse the repository at this point in the history
Co-authored-by: Dingmeng Xue <[email protected]>
  • Loading branch information
VeryEarly and dingmeng-xue authored Feb 24, 2021
1 parent 75e94c4 commit 8e7038c
Show file tree
Hide file tree
Showing 445 changed files with 16,466 additions and 7,881 deletions.
544 changes: 398 additions & 146 deletions src/ResourceMover/Az.ResourceMover.format.ps1xml

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/ResourceMover/Az.ResourceMover.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 9/15/2020
# Generated on: 2/24/2021
#

@{
Expand Down Expand Up @@ -45,7 +45,7 @@ PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
Expand All @@ -72,8 +72,10 @@ FormatsToProcess = './Az.ResourceMover.format.ps1xml'
FunctionsToExport = 'Add-AzResourceMoverMoveResource',
'Get-AzResourceMoverMoveCollection',
'Get-AzResourceMoverMoveResource',
'Get-AzResourceMoverRequiredForResources',
'Get-AzResourceMoverUnresolvedDependency',
'Invoke-AzResourceMoverCommit', 'Invoke-AzResourceMoverDiscard',
'Invoke-AzResourceMoverBulkRemove', 'Invoke-AzResourceMoverCommit',
'Invoke-AzResourceMoverDiscard',
'Invoke-AzResourceMoverInitiateMove',
'Invoke-AzResourceMoverPrepare',
'New-AzResourceMoverMoveCollection',
Expand All @@ -88,7 +90,7 @@ CmdletsToExport = @()
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
AliasesToExport = 'Update-AzResourceMoverMoveResource', '*'

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down Expand Up @@ -117,7 +119,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* First preview release for module Az.ResourceMover'
# ReleaseNotes = ''

# Prerelease string of this module
# Prerelease = ''
Expand Down
10 changes: 5 additions & 5 deletions src/ResourceMover/Az.ResourceMover.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
}
}
if(-not $accountsModule) {
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'2.2.3' } | Measure-Object).Count -gt 0
if($hasAdequateVersion) {
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 2.2.3 -Scope Global -PassThru
}
}
}

if(-not $accountsModule) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
}
Write-Information "Loaded Module '$($accountsModule.Name)'"

Expand Down
3 changes: 3 additions & 0 deletions src/ResourceMover/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
- Additional information about change #1
-->
## Upcoming Release
* Added new cmdlets `Invoke-AzResourceMoverBulkRemove`, `Get-AzResourceMoverRequiredForResources`
* Added alias to `Add-AzResourceMoverMoveResource`: `Update-AzResourceMoverMoveResource`
* Flattened object "ResourceSettings"

## Version 0.1.0
* First preview release for module Az.ResourceMover
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceMover/build-module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $null = New-Item -ItemType Directory -Force -Path $examplesFolder

if($NoDocs) {
Write-Host -ForegroundColor Green 'Creating exports...'
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder
} else {
Write-Host -ForegroundColor Green 'Creating exports and docs...'
$moduleDescription = 'Microsoft Azure PowerShell: ResourceMover cmdlets'
Expand Down
4 changes: 2 additions & 2 deletions src/ResourceMover/check-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if(Test-Path -Path $localModulesPath) {
$env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
}

DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1'
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '2.2.3'
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'

$tools = Join-Path $PSScriptRoot 'tools'
Expand All @@ -56,7 +56,7 @@ $resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestS
if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) {
Write-Host -ForegroundColor Green "Building local Resource module used for test..."
Set-Location $resourceDir
$null = autorest-beta .\readme.md --output-folder=$HOME/.PSSharedModules/Resources
$null = autorest .\readme.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
$null = Copy-Item custom/* $HOME/.PSSharedModules/Resources/custom/
Set-Location $HOME/.PSSharedModules/Resources
$null = .\build-module.ps1
Expand Down
8 changes: 4 additions & 4 deletions src/ResourceMover/custom/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ These provide functionality to our HTTP pipeline and other useful features. In s

### Attributes
For processing the cmdlets, we've created some additional attributes:
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.DescriptionAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.DescriptionAttribute`
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.DoNotExportAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.DoNotExportAttribute`
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.ResourceMover`.
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.InternalExportAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.InternalExportAttribute`
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.ResourceMover`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder.
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.ProfileAttribute`
- `Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.ProfileAttribute`
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
138 changes: 101 additions & 37 deletions src/ResourceMover/examples/Add-AzResourceMoverMoveResource.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,105 @@
### Example 1: Adding a resource to the move collection.
### Example 1: Add a resource to the Move Collection.
```powershell
PS C:\> Add-AzResourceMoverMoveResource -ResourceGroupName RG-MoveCollection-demoRM -MoveCollectionName "PS-centralus-westcentralus-demoRM" -SourceId "/subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM" -Name PSDemoVM -ResourceSettingResourceType "Microsoft.Compute/virtualMachines" -ResourceSettingTargetResourceName PSDemoVM
Output:
Code :
DependsOn : {}
DependsOnOverride : {}
Detail :
ExistingTargetId :
Id : /subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/RG-MoveCollection-demoRM/providers/Microsoft.Migr
ate/MoveCollections/PS-centralus-westcentralus-demoRM/MoveResources/PSDemoVM
Message :
MoveStatusCode : DependencyComputationPending
MoveStatusDetail : {}
MoveStatusJobName :
MoveStatusJobProgress :
MoveStatusMessage : The dependency computation is not completed for resource - /subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resou
rceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM.
Possible Causes: Dependency computation is pending for resource.
Recommended Action: Validate dependencies to compute the dependencies.
MoveStatusMoveState : PreparePending
MoveStatusTarget :
MoveStatusTargetId :
Name : PSDemoVM
ProvisioningState : Succeeded
ResourceSettingResourceType : Microsoft.Compute/virtualMachines
ResourceSettingTargetResourceName : PSDemoVM
SourceId : /subscriptions/e80eb9fa-c996-4435-aa32-5af6f3d3077c/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachi
nes/PSDemoVM
SourceResourceSettingResourceType : Microsoft.Compute/virtualMachines
SourceResourceSettingTargetResourceName : PSDemoVM
Target :
TargetId :
Type
PS C:\> Add-AzResourceMoverMoveResource -ResourceGroupName "RG-MoveCollection-demoRMS" -MoveCollectionName "PS-centralus-westcentralus-demoRMS" -SourceId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM" -Name "PSDemoVM" -ResourceSetting $targetResourceSettingsObj
DependsOn : {}
DependsOnOverride : {}
ErrorsPropertiesCode :
ErrorsPropertiesDetail :
ErrorsPropertiesMessage :
ErrorsPropertiesTarget :
ExistingTargetId :
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/RG-MoveCollection-demoRMS/providers/Microsoft.Migrate/moveCollections/PS-centralus-westcentralus-demoRMS/moveResources/PSDemoVM
IsResolveRequired : False
JobStatusJobName :
JobStatusJobProgress :
MoveStatusErrorsPropertiesCode : DependencyComputationPending
MoveStatusErrorsPropertiesDetail : {}
MoveStatusErrorsPropertiesMessage : The dependency computation is not completed for resource - /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM. Possible Causes: Dependency computation is pending for resource. Recommended Action: Validate dependencies to compute the dependencies.
MoveStatusErrorsPropertiesTarget :
MoveStatusMoveState : PreparePending
Name : PSDemoVM
ProvisioningState : Succeeded
ResourceSetting : Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings
SourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM
SourceResourceSetting : Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings
TargetId :
Type :
PS C:\> $targetResourceSettingsObj = New-Object Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings
PS C:\> $targetResourceSettingsObj.ResourceType = "Microsoft.Compute/virtualMachines"
$targetResourceSettingsObj.TargetResourceName = "PSDemoVM"
```

Add a resource to the Move Collection.

### Example 2: Add a resource to the Move Collection that has existing target resource.
```powershell
PS C:\> Add-AzResourceMoverMoveResource -ResourceGroupName "RG-MoveCollection-demoRMS" -MoveCollectionName "PS-centralus-westcentralus-demoRMS" -SourceId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/psdemorm" -Name "psdemorm" -ExistingTargetId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/PSDemoRM-target"
DependsOn : {}
DependsOnOverride : {}
ErrorsPropertiesCode :
ErrorsPropertiesDetail :
ErrorsPropertiesMessage :
ErrorsPropertiesTarget :
ExistingTargetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/PSDemoRM-target
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/RG-MoveCollection-demoRMS/providers/Microsoft.Migrate/moveCollections/PS-centralus-westcentralus-demoRMS/moveResources/psdemorm
IsResolveRequired : False
JobStatusJobName :
JobStatusJobProgress :
MoveStatusErrorsPropertiesCode :
MoveStatusErrorsPropertiesDetail :
MoveStatusErrorsPropertiesMessage :
MoveStatusErrorsPropertiesTarget :
MoveStatusMoveState : CommitPending
Name : psdemorm
ProvisioningState : Succeeded
ResourceSetting : Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.ResourceSettings
SourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/psdemorm
SourceResourceSetting : Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.ResourceSettings
TargetId :
Type :
```

Add a resource to the Move Collection that has existing target resource.

### Example 3: Update target resource settings after the Move Resource has been added.
```powershell
PS C:\> Update-AzResourceMoverMoveResource -ResourceGroupName "RG-MoveCollection-demoRMS" -MoveCollectionName "PS-centralus-westcentralus-demoRMS" -SourceId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM" -Name "PSDemoVM" -ResourceSetting $TargetResourceSettingObj
DependsOn : {/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/PSDemoRM/providers/Microsoft.Network/networkInterfaces/psdemov
m111, /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/PSDemoRM}
DependsOnOverride : {}
ErrorsPropertiesCode :
ErrorsPropertiesDetail :
ErrorsPropertiesMessage :
ErrorsPropertiesTarget :
ExistingTargetId :
Id : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/RG-MoveCollection-demoRMS/providers/Microsoft.Migrate/moveCollections/PS-centralus-westcentralus-demoRMS/moveResources/PSDemoVM
IsResolveRequired : True
JobStatusJobName :
JobStatusJobProgress :
MoveStatusErrorsPropertiesCode :
MoveStatusErrorsPropertiesDetail :
MoveStatusErrorsPropertiesMessage :
MoveStatusErrorsPropertiesTarget :
MoveStatusMoveState : PreparePending
Name : PSDemoVM
ProvisioningState : Succeeded
ResourceSetting : Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings
SourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/PSDemoRM/providers/Microsoft.Compute/virtualMachines/PSDemoVM
SourceResourceSetting : Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api202101.VirtualMachineResourceSettings
TargetId :
Type :
PS C:\> $moveResourceObj = Get-AzResourceMoverMoveResource -MoveCollectionName "PS-centralus-westcentralus-demoRMS1" -ResourceGroupName "RG-MoveCollection-demoRMS" -Name "PSDemoVM"
PS C:\> $TargetResourceSettingObj = $moveResourceObj.ResourceSetting
$TargetResourceSettingObj.TargetResourceName="PSDemoVM-target"
```

Adding a resource to the move collection within the specified subscription.
Update target resource settings after the Move Resource has been added.
Loading

0 comments on commit 8e7038c

Please sign in to comment.