Skip to content

Commit 26c88f9

Browse files
committed
Correcting the validation for delete vault
1 parent 69eed75 commit 26c88f9

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/PSRecoveryServicesClient/PSRecoveryServicesServerClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ public partial class PSRecoveryServicesClient
2626
/// <summary>
2727
/// Gets Azure Site Recovery Servers.
2828
/// </summary>
29+
/// <param name="shouldSignRequest">Boolean indicating if the request should be signed ACIK</param>
2930
/// <returns>Server list response</returns>
30-
public ServerListResponse GetAzureSiteRecoveryServer()
31+
public ServerListResponse GetAzureSiteRecoveryServer(bool shouldSignRequest = true)
3132
{
32-
return this.GetSiteRecoveryClient().Servers.List(this.GetRequestHeaders());
33+
return this.GetSiteRecoveryClient().Servers.List(this.GetRequestHeaders(shouldSignRequest));
3334
}
3435

3536
/// <summary>

src/ServiceManagement/RecoveryServices/Commands.RecoveryServices/Service/RemoveAzureSiteRecoveryVault.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Net;
1818
using Microsoft.Azure.Commands.RecoveryServices.Properties;
1919
using Microsoft.Azure.Commands.RecoveryServices.SiteRecovery;
20+
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
2021
using Microsoft.WindowsAzure.Management.RecoveryServices.Models;
2122
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;
2223

@@ -58,12 +59,16 @@ public override void ExecuteCmdlet()
5859
{
5960
try
6061
{
62+
// Update vault settings with the working vault
63+
Utilities.UpdateVaultSettings(new ASRVaultCreds()
64+
{
65+
CloudServiceName = this.Vault.CloudServiceName,
66+
ResourceName = this.Vault.Name
67+
});
68+
6169
// Check if vault has servers registered to it - prevent the operation.
62-
// Invocation of the api directly will result in a call similar to purge
63-
// But here we can't modify at service level.
64-
// Impact of this check on user is that the vault settings file has to be imported for this to work
6570
ServerListResponse serverListResponse =
66-
RecoveryServicesClient.GetAzureSiteRecoveryServer();
71+
RecoveryServicesClient.GetAzureSiteRecoveryServer(false);
6772

6873
if (serverListResponse.Servers.Count != 0)
6974
{

0 commit comments

Comments
 (0)