Skip to content

Commit 4ef6279

Browse files
haaghaBethanyZhou
andauthored
[Compute] New-AzRestorePoint and New-AzRestorePointCollection (#17665)
* Powershell updates * Powershell updates * help file update * updates to help and parametersets * parameter sets * Update src/Compute/Compute/ChangeLog.md Co-authored-by: Beisi Zhou <[email protected]> * Updates for PR changes requested. * description update * Update BreakingChangeIssues.csv * update help Co-authored-by: Beisi Zhou <[email protected]>
1 parent 2d5322d commit 4ef6279

File tree

9 files changed

+254
-56
lines changed

9 files changed

+254
-56
lines changed

src/Compute/Compute/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* Updated `Get-AzVm` to include `GetVirtualMachineById` parameter set.
2626
* Edited the documentation for the cmdlet `Set-AzVMADDomainExtension` to ensure the example is accurate.
2727
* Improved description and examples for disk creation.
28+
* Added new parameters to `New-AzRestorePoint` and `New-AzRestorePointCollection` for copying Restore Points and Restore Point Collections.
29+
* Added `Zone` and `PlacementGroupId` Parameters to `Repair-AzVmssServiceFabricUpdateDomain`.
2830

2931
## Version 4.24.1
3032
* Updated New-AzVM feature for `vCPUsAvailable` and `vCPUsPerCore` parameters. Cmdlets will not try to use the new `VMCustomizationPreview` feature if the user does not have access to that feature. [#17370]

src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetForceRecoveryServiceFabricPlatformUpdateDomainWalkMethod.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public override void ExecuteCmdlet()
4646
{
4747
string resourceGroupName;
4848
string vmScaleSetName;
49+
string zone = this.Zone;
50+
string placementgroupid = this.PlacementGroupId;
51+
4952
switch (this.ParameterSetName)
5053
{
5154
case "ResourceIdParameter":
@@ -62,8 +65,7 @@ public override void ExecuteCmdlet()
6265
break;
6366
}
6467
int platformUpdateDomain = this.PlatformUpdateDomain;
65-
66-
var result = VirtualMachineScaleSetsClient.ForceRecoveryServiceFabricPlatformUpdateDomainWalk(resourceGroupName, vmScaleSetName, platformUpdateDomain);
68+
var result = VirtualMachineScaleSetsClient.ForceRecoveryServiceFabricPlatformUpdateDomainWalk(resourceGroupName, vmScaleSetName, platformUpdateDomain, zone: zone, placementGroupId: placementgroupid);
6769
var psObject = new PSRecoveryWalkResponse();
6870
ComputeAutomationAutoMapperProfile.Mapper.Map<RecoveryWalkResponse, PSRecoveryWalkResponse>(result, psObject);
6971
WriteObject(psObject);
@@ -93,6 +95,16 @@ public override void ExecuteCmdlet()
9395
Mandatory = true)]
9496
public int PlatformUpdateDomain { get; set; }
9597

98+
[Parameter(
99+
Mandatory = false,
100+
HelpMessage = "Set the Zone for the VMSS")]
101+
public string Zone { get; set; }
102+
103+
[Parameter(
104+
Mandatory = false,
105+
HelpMessage = "Set the Placement Group Id")]
106+
public string PlacementGroupId { get; set; }
107+
96108
[Parameter(
97109
ParameterSetName = "ResourceIdParameter",
98110
Position = 0,

src/Compute/Compute/RestorePoints/NewAzRestorePoint.cs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ public class NewAzureRestorePoint : ComputeAutomationBaseCmdlet
5353

5454
[Parameter(
5555
Position = 3,
56+
Mandatory = false,
57+
ValueFromPipelineByPropertyName = false,
58+
HelpMessage = "Set the region of the Restore Point")]
59+
public string Location { get; set; }
60+
61+
62+
[Parameter(
63+
Mandatory = false,
64+
ValueFromPipeline = true,
65+
HelpMessage = "ARM Id of the source Restore Point")]
66+
public string RestorePointId { get; set; }
67+
68+
69+
[Parameter(
5670
Mandatory = false,
5771
ValueFromPipeline = true)]
5872
public string[] DisksToExclude { get; set; }
@@ -68,29 +82,31 @@ public override void ExecuteCmdlet()
6882
string resourceGroup = this.ResourceGroupName;
6983
string restorePointName = this.Name;
7084
string restorePointCollectionName = this.RestorePointCollectionName;
85+
string location = this.Location;
86+
string restorePointId = this.RestorePointId;
7187
List<ApiEntityReference> disksExclude = new List<ApiEntityReference>();
7288

7389
RestorePoint restorePoint = new RestorePoint();
90+
91+
if(this.IsParameterBound(c=> c.RestorePointId))
92+
{
93+
restorePoint.SourceRestorePoint = new ApiEntityReference { Id = restorePointId };
94+
}
95+
7496
if (this.IsParameterBound(c => c.DisksToExclude))
7597
{
7698
foreach (string s in DisksToExclude)
7799
{
78100
disksExclude.Add(new ApiEntityReference(s));
79101
}
80102
restorePoint.ExcludeDisks = disksExclude;
81-
var result = RestorePointClient.Create(resourceGroup, restorePointCollectionName, restorePointName, restorePoint);
82-
var psObject = new PSRestorePoint();
83-
ComputeAutomationAutoMapperProfile.Mapper.Map<RestorePoint, PSRestorePoint>(result, psObject);
84-
WriteObject(psObject);
85-
86-
}
87-
else
88-
{
89-
var result = RestorePointClient.Create(resourceGroup, restorePointCollectionName, restorePointName, restorePoint);
90-
var psObject = new PSRestorePoint();
91-
ComputeAutomationAutoMapperProfile.Mapper.Map<RestorePoint, PSRestorePoint>(result, psObject);
92-
WriteObject(psObject);
93103
}
104+
105+
var result = RestorePointClient.Create(resourceGroup, restorePointCollectionName, restorePointName, restorePoint);
106+
107+
var psObject = new PSRestorePoint();
108+
ComputeAutomationAutoMapperProfile.Mapper.Map<RestorePoint, PSRestorePoint>(result, psObject);
109+
WriteObject(psObject);
94110
}
95111
});
96112
}

src/Compute/Compute/RestorePoints/NewAzRestorePointCollection.cs

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public class NewAzureRestorePointCollection : ComputeAutomationBaseCmdlet
3232
{
3333

3434
[Parameter(
35+
ParameterSetName = "DefaultParameter",
36+
Position = 0,
37+
Mandatory = true,
38+
ValueFromPipelineByPropertyName = true)]
39+
[Parameter(
40+
ParameterSetName = "RestorePointCollectionId",
3541
Position = 0,
3642
Mandatory = true,
3743
ValueFromPipelineByPropertyName = true)]
@@ -40,6 +46,12 @@ public class NewAzureRestorePointCollection : ComputeAutomationBaseCmdlet
4046

4147
[Parameter(
4248
Position = 1,
49+
ParameterSetName = "DefaultParameter",
50+
Mandatory = true,
51+
ValueFromPipelineByPropertyName = true)]
52+
[Parameter(
53+
Position = 1,
54+
ParameterSetName = "RestorePointCollectionId",
4355
Mandatory = true,
4456
ValueFromPipelineByPropertyName = true)]
4557
[Alias("RestorePointCollectionName")]
@@ -48,35 +60,81 @@ public class NewAzureRestorePointCollection : ComputeAutomationBaseCmdlet
4860
[Parameter(
4961
Position = 2,
5062
Mandatory = true,
51-
ValueFromPipeline = true)]
63+
ValueFromPipeline = true,
64+
ParameterSetName = "DefaultParameter")]
65+
[Parameter(
66+
Position = 2,
67+
Mandatory = false,
68+
ValueFromPipeline = true,
69+
ParameterSetName = "RestorePointCollectionId")]
5270
public string VmId { get; set; }
5371

5472
[Parameter(
5573
Position = 3,
5674
Mandatory = true,
75+
ValueFromPipeline = true,
76+
ParameterSetName = "RestorePointCollectionId",
77+
HelpMessage = "ARM Id for the source Restore Point Collection")]
78+
public string RestorePointCollectionId { get; set; }
79+
80+
[Parameter(
81+
ParameterSetName = "DefaultParameter",
82+
Mandatory = false,
5783
ValueFromPipeline = true)]
84+
[Parameter(
85+
ParameterSetName = "RestorePointCollectionId",
86+
Mandatory = true,
87+
ValueFromPipeline = true,
88+
HelpMessage = "Location of the source Restore Point Collection")]
5889
public string Location { get; set; }
5990

60-
6191
public override void ExecuteCmdlet()
6292
{
6393
base.ExecuteCmdlet();
6494
ExecuteClientAction(() =>
6595
{
6696
if (ShouldProcess(this.Name, VerbsCommon.New))
6797
{
68-
string resourceGroup = this.ResourceGroupName;
69-
string restorePointCollectionName = this.Name;
70-
string vmId = this.VmId;
71-
string location = this.Location;
98+
if (ParameterSetName == "DefaultParameter")
99+
{
100+
string resourceGroup = this.ResourceGroupName;
101+
string restorePointCollectionName = this.Name;
102+
string vmId = this.VmId;
103+
RestorePointCollection restorePointCollection;
104+
if (this.IsParameterBound(c => c.Location))
105+
{
106+
string location = this.Location;
107+
restorePointCollection = new RestorePointCollection(location);
108+
restorePointCollection.Source = new RestorePointCollectionSourceProperties() { Id = vmId };
109+
110+
}
111+
else
112+
{
113+
restorePointCollection = new RestorePointCollection();
114+
restorePointCollection.Source = new RestorePointCollectionSourceProperties() { Id = vmId };
115+
116+
}
117+
118+
var result = RestorePointCollectionsClient.CreateOrUpdate(resourceGroup, restorePointCollectionName, restorePointCollection);
119+
var psObject = new PSRestorePointCollection();
120+
ComputeAutomationAutoMapperProfile.Mapper.Map<RestorePointCollection, PSRestorePointCollection>(result, psObject);
121+
WriteObject(psObject);
122+
}
123+
else if(ParameterSetName == "RestorePointCollectionId")
124+
{
125+
string resourceGroup = this.ResourceGroupName;
126+
string restorePointCollectionName = this.Name;
127+
string restorePointCollectionId = this.RestorePointCollectionId;
128+
string location = this.Location;
72129

73-
RestorePointCollection restorePointCollection = new RestorePointCollection(location);
74-
restorePointCollection.Source = new RestorePointCollectionSourceProperties() { Id = vmId };
130+
RestorePointCollection restorePointCollection = new RestorePointCollection(location, restorePointCollectionId: restorePointCollectionId);
131+
restorePointCollection.Source = new RestorePointCollectionSourceProperties(location, RestorePointCollectionId);
75132

76-
var result = RestorePointCollectionsClient.CreateOrUpdate(resourceGroup, restorePointCollectionName, restorePointCollection);
77-
var psObject = new PSRestorePointCollection();
78-
ComputeAutomationAutoMapperProfile.Mapper.Map<RestorePointCollection, PSRestorePointCollection>(result, psObject);
79-
WriteObject(psObject);
133+
var result = RestorePointCollectionsClient.CreateOrUpdate(resourceGroup, restorePointCollectionName, restorePointCollection);
134+
var psObject = new PSRestorePointCollection();
135+
ComputeAutomationAutoMapperProfile.Mapper.Map<RestorePointCollection, PSRestorePointCollection>(result, psObject);
136+
WriteObject(psObject);
137+
}
80138
}
81139
});
82140
}

src/Compute/Compute/help/Az.Compute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Configures the DSC extension on a virtual machine.
615615
Updates extension properties or adds an extension to a virtual machine.
616616

617617
### [Set-AzVMOperatingSystem](Set-AzVMOperatingSystem.md)
618-
Sets operating system properties for a virtual machine.
618+
Sets operating system properties during the creation of a new virtual machine.
619619

620620
### [Set-AzVMOSDisk](Set-AzVMOSDisk.md)
621621
Sets the operating system disk properties on a virtual machine.

src/Compute/Compute/help/New-AzRestorePoint.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This cmdlet can create a New Restore Point
1414

1515
```
1616
New-AzRestorePoint [-ResourceGroupName] <String> [-RestorePointCollectionName] <String> [-Name] <String>
17-
[[-DisksToExclude] <String[]>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
18-
[<CommonParameters>]
17+
[[-Location] <String>] [-RestorePointId <String>] [-DisksToExclude <String[]>]
18+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
1919
```
2020

2121
## DESCRIPTION
@@ -36,7 +36,7 @@ Creates a new Restore Point
3636
The credentials, account, tenant, and subscription used for communication with Azure.
3737

3838
```yaml
39-
Type: IAzureContextContainer
39+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
4040
Parameter Sets: (All)
4141
Aliases: AzContext, AzureRmContext, AzureCredential
4242

@@ -51,22 +51,37 @@ Accept wildcard characters: False
5151
List of disk resource ids that the customer wishes to exclude from the restorepoint. If no disks are specified, all disks will be included.
5252
5353
```yaml
54-
Type: String[]
54+
Type: System.String[]
5555
Parameter Sets: (All)
5656
Aliases:
5757

5858
Required: False
59-
Position: 3
59+
Position: Named
6060
Default value: None
6161
Accept pipeline input: True (ByValue)
6262
Accept wildcard characters: False
6363
```
6464
65+
### -Location
66+
{{ Fill Location Description }}
67+
68+
```yaml
69+
Type: System.String
70+
Parameter Sets: (All)
71+
Aliases:
72+
73+
Required: False
74+
Position: 3
75+
Default value: None
76+
Accept pipeline input: False
77+
Accept wildcard characters: False
78+
```
79+
6580
### -Name
6681
Resource Name
6782
6883
```yaml
69-
Type: String
84+
Type: System.String
7085
Parameter Sets: (All)
7186
Aliases: RestorePointName
7287

@@ -81,7 +96,7 @@ Accept wildcard characters: False
8196
Resource Group Name
8297
8398
```yaml
84-
Type: String
99+
Type: System.String
85100
Parameter Sets: (All)
86101
Aliases:
87102

@@ -96,7 +111,7 @@ Accept wildcard characters: False
96111
Restore Point Collection Name
97112
98113
```yaml
99-
Type: String
114+
Type: System.String
100115
Parameter Sets: (All)
101116
Aliases:
102117

@@ -107,11 +122,26 @@ Accept pipeline input: True (ByPropertyName)
107122
Accept wildcard characters: False
108123
```
109124
125+
### -RestorePointId
126+
{{ Fill RestorePointId Description }}
127+
128+
```yaml
129+
Type: System.String
130+
Parameter Sets: (All)
131+
Aliases:
132+
133+
Required: False
134+
Position: Named
135+
Default value: None
136+
Accept pipeline input: True (ByValue)
137+
Accept wildcard characters: False
138+
```
139+
110140
### -Confirm
111141
Prompts you for confirmation before running the cmdlet.
112142
113143
```yaml
114-
Type: SwitchParameter
144+
Type: System.Management.Automation.SwitchParameter
115145
Parameter Sets: (All)
116146
Aliases: cf
117147

@@ -127,7 +157,7 @@ Shows what would happen if the cmdlet runs.
127157
The cmdlet is not run.
128158
129159
```yaml
130-
Type: SwitchParameter
160+
Type: System.Management.Automation.SwitchParameter
131161
Parameter Sets: (All)
132162
Aliases: wi
133163

0 commit comments

Comments
 (0)