Skip to content

Commit 6895f65

Browse files
committed
Updated help, changelog and table format
1 parent 1f22013 commit 6895f65

File tree

9 files changed

+151
-30
lines changed

9 files changed

+151
-30
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,18 @@ public void TestAzureVMRPMountScript()
107107

108108
Assert.True(AzureSession.Instance.DataStore.FileExists(mountScriptDetails.FilePath));
109109
}
110+
111+
#if NETSTANDARD
112+
[Fact(Skip = "Needs investigation, TestManagementClientHelper class wasn't initialized with the ResourceManagementClient client.")]
113+
#else
114+
[Fact]
115+
#endif
116+
[Trait(Category.AcceptanceType, Category.CheckIn)]
117+
[Trait(TestConstants.Workload, TestConstants.AzureVM)]
118+
public void TestAzureVMSetVaultContext()
119+
{
120+
TestController.NewInstance.RunPsTest(
121+
_logger, PsBackupProviderTypes.IaasVm, "Test-AzureVMSetVaultContext");
122+
}
110123
}
111124
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,51 @@ function Test-AzureVMBackup
348348
# Cleanup
349349
Cleanup-ResourceGroup $resourceGroupName
350350
}
351+
}
352+
353+
function Test-AzureVMSetVaultContext
354+
{
355+
$location = Get-ResourceGroupLocation
356+
$resourceGroupName = Create-ResourceGroup $location
357+
358+
try
359+
{
360+
# Setup
361+
$vm = Create-VM $resourceGroupName $location
362+
$vault = Create-RecoveryServicesVault $resourceGroupName $location
363+
364+
# Sleep to give the service time to add the default policy to the vault
365+
Start-TestSleep 5000
366+
367+
Set-AzureRmRecoveryServicesVaultContext -Vault $vault
368+
369+
# Get default policy
370+
$policy = Get-AzureRmRecoveryServicesBackupProtectionPolicy `
371+
-Name "DefaultPolicy";
372+
373+
# Enable protection
374+
Enable-AzureRmRecoveryServicesBackupProtection `
375+
-Policy $policy `
376+
-Name $vm.Name `
377+
-ResourceGroupName $vm.ResourceGroupName;
378+
379+
$container = Get-AzureRmRecoveryServicesBackupContainer `
380+
-ContainerType AzureVM `
381+
-Status Registered;
382+
383+
$item = Get-AzureRmRecoveryServicesBackupItem `
384+
-Container $container `
385+
-WorkloadType AzureVM
386+
387+
# Disable protection
388+
Disable-AzureRmRecoveryServicesBackupProtection `
389+
-Item $item `
390+
-RemoveRecoveryPoints `
391+
-Force;
392+
}
393+
finally
394+
{
395+
# Cleanup
396+
Cleanup-ResourceGroup $resourceGroupName
397+
}
351398
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup/ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
* Overview of change #1
1818
- Additional information about change #1
1919
-->
20-
## Current Release
20+
## Current Release
21+
* Removed Name Parameter in Get-Container cmdlet.

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup/Microsoft.Azure.Commands.RecoveryServices.Backup.format.ps1xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<TableControl>
4040
<TableHeaders>
4141
<TableColumnHeader>
42-
<Label>Name</Label>
42+
<Label>FriendlyName</Label>
4343
<Width>40</Width>
4444
</TableColumnHeader>
4545
<TableColumnHeader>
@@ -287,7 +287,7 @@
287287
<TableControl>
288288
<TableHeaders>
289289
<TableColumnHeader>
290-
<Label>Name</Label>
290+
<Label>FriendlyName</Label>
291291
<Width>40</Width>
292292
</TableColumnHeader>
293293
<TableColumnHeader>
@@ -331,7 +331,7 @@
331331
<TableControl>
332332
<TableHeaders>
333333
<TableColumnHeader>
334-
<Label>Name</Label>
334+
<Label>FriendlyName</Label>
335335
<Width>40</Width>
336336
</TableColumnHeader>
337337
<TableColumnHeader>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/RecoveryServicesTests.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ function Test-RecoveryServicesVaultCRUD
108108
Assert-NotNull($vault1.ID)
109109
Assert-NotNull($vault1.Type)
110110

111-
# 2. Get-AzureRmRecoveryServicesVault
111+
# 2. Set-AzureRmRecoveryServicesVault
112+
Set-AzureRmRecoveryServicesVaultContext -Vault $vault1
113+
114+
# 3. Get-AzureRmRecoveryServicesVault
112115
$vaults = Get-AzureRmRecoveryServicesVault -Name $name -ResourceGroupName $resourceGroupName
113116

114117
Assert-NotNull($vaults)
@@ -120,15 +123,15 @@ function Test-RecoveryServicesVaultCRUD
120123
Assert-NotNull($vault.Type)
121124
}
122125

123-
# 3. Get-AzureRmRecoveryServicesBackupProperty
126+
# 4. Get-AzureRmRecoveryServicesBackupProperty
124127
$vaultBackupProperties = Get-AzureRmRecoveryServicesBackupProperty -Vault $vault1
125128

126129
Assert-NotNull($vaultBackupProperties.BackupStorageRedundancy)
127130

128-
# 4. Set-AzureRmRecoveryServicesBackupProperties
131+
# 5. Set-AzureRmRecoveryServicesBackupProperties
129132
Set-AzureRmRecoveryServicesBackupProperties -Vault $vault1 -BackupStorageRedundancy LocallyRedundant
130133

131-
# 5. Remove-AzureRmRecoveryServicesVault
134+
# 6. Remove-AzureRmRecoveryServicesVault
132135
Remove-AzureRmRecoveryServicesVault -Vault $vault1
133136

134137
$vaults = Get-AzureRmRecoveryServicesVault -ResourceGroupName $resourceGroupName -Name $name

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Compile Include="Vault\NewAzureRmRecoveryServicesVault.cs" />
7070
<Compile Include="Vault\RemoveAzureRmRecoveryServicesVault.cs" />
7171
<Compile Include="Vault\SetAzureRmRecoveryServicesBackupProperties.cs" />
72+
<Compile Include="Vault\SetAzureRmRecoveryServicesVaultContext.cs" />
7273
</ItemGroup>
7374
<ItemGroup>
7475
<EmbeddedResource Include="Properties\Resources.resx">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Linq;
17+
using System.Management.Automation;
18+
using System.Security.Cryptography.X509Certificates;
19+
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
20+
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
21+
22+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
23+
{
24+
/// <summary>
25+
/// Used to set RecoveryServices Vault Context
26+
/// </summary>
27+
[CmdletDeprecation("This command is getting deprecated. Please use -VaultID parameter in all Recovery Services commands going forward.")]
28+
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesVaultContext"), OutputType(typeof(void))]
29+
public class SetAzureRmRecoveryServicesVaultContext : RecoveryServicesCmdletBase
30+
{
31+
[Parameter(Mandatory = true, ValueFromPipeline = true)]
32+
[ValidateNotNullOrEmpty]
33+
public ARSVault Vault { get; set; }
34+
35+
public override void ExecuteCmdlet()
36+
{
37+
try
38+
{
39+
base.ExecuteCmdlet();
40+
41+
// Validate required parameters taken from the Vault.
42+
if (string.IsNullOrEmpty(Vault.Name))
43+
{
44+
throw new ArgumentException(
45+
Properties.Resources.ResourceNameNullOrEmpty,
46+
Vault.Name);
47+
}
48+
49+
if (string.IsNullOrEmpty(Vault.ResourceGroupName))
50+
{
51+
throw new ArgumentException(
52+
Properties.Resources.ResourceGroupNameNullOrEmpty,
53+
Vault.ResourceGroupName);
54+
}
55+
56+
var vault = RecoveryServicesClient.GetVault(Vault.ResourceGroupName, Vault.Name);
57+
if (vault == null)
58+
{
59+
throw new ArgumentException(
60+
string.Format(Properties.Resources.VaultNotFound, Vault.Name),
61+
Vault.ResourceGroupName);
62+
}
63+
64+
Utilities.UpdateCurrentVaultContext(Vault);
65+
}
66+
catch (Exception exception)
67+
{
68+
this.HandleException(exception);
69+
}
70+
71+
}
72+
}
73+
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/help/Get-AzRecoveryServicesBackupContainer.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
external help file: Microsoft.Azure.Commands.RecoveryServices.Backup.dll-Help.xml
3-
Module Name: Az.RecoveryServices
3+
Module Name: Az.RecoveryServices.Backup
44
ms.assetid: 1097FF29-1C23-4960-930C-5C1227419359
55
online version: https://docs.microsoft.com/en-us/powershell/module/az.recoveryservices.backup/get-azrecoveryservicesbackupcontainer
66
schema: 2.0.0
@@ -15,9 +15,8 @@ Gets Backup containers.
1515

1616
```
1717
Get-AzRecoveryServicesBackupContainer [-ContainerType] <ContainerType> [[-BackupManagementType] <String>]
18-
[[-Name] <String>] [[-FriendlyName] <String>] [[-ResourceGroupName] <String>]
19-
[[-Status] <ContainerRegistrationStatus>] [-VaultId <String>] [-DefaultProfile <IAzureContextContainer>]
20-
[<CommonParameters>]
18+
[[-FriendlyName] <String>] [[-ResourceGroupName] <String>] [[-Status] <ContainerRegistrationStatus>]
19+
[-VaultId <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2120
```
2221

2322
## DESCRIPTION
@@ -94,7 +93,7 @@ The credentials, account, tenant, and subscription used for communication with a
9493
```yaml
9594
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
9695
Parameter Sets: (All)
97-
Aliases: AzureRmContext, AzureCredential
96+
Aliases: AzContext, AzureCredential
9897

9998
Required: False
10099
Position: Named
@@ -118,21 +117,6 @@ Accept pipeline input: False
118117
Accept wildcard characters: False
119118
```
120119
121-
### -Name
122-
Specifies the name of the container to get.
123-
124-
```yaml
125-
Type: System.String
126-
Parameter Sets: (All)
127-
Aliases:
128-
129-
Required: False
130-
Position: 3
131-
Default value: None
132-
Accept pipeline input: False
133-
Accept wildcard characters: False
134-
```
135-
136120
### -ResourceGroupName
137121
Specifies the name of the resource group.
138122
This parameter is for Azure virtual machines only.
@@ -204,4 +188,3 @@ Parameters: VaultId (ByValue)
204188
205189
[Unregister-AzRecoveryServicesBackupContainer](./Unregister-AzRecoveryServicesBackupContainer.md)
206190
207-

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/help/Set-AzRecoveryServicesVaultContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ Parameters: Vault (ByValue)
7777
7878
## NOTES
7979
80-
## RELATED LINKS
80+
## RELATED LINKS

0 commit comments

Comments
 (0)