Azure / PSRule.Rules.Azure

Rules to validate Azure resources and infrastructure as code (IaC) using PSRule.
https://azure.github.io/PSRule.Rules.Azure/
MIT License
387 stars 84 forks source link

Set-AzRecoveryServicesAsrVaultContext : Operation failed. #647

Closed Manvendra11 closed 3 years ago

Manvendra11 commented 3 years ago

Description of the issue WARNING: Unable to cast object of type 'Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext' to type 'Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureContext '. Set-AzRecoveryServicesAsrVaultContext : Operation failed. Download vault credential file using cmdlet Get-AzRecoveryServicesVaultSettingsFile and Import-AzRecoveryServicesAsrVaultSettingsFile At line:1 char:1

To Reproduce $Sub = Get-AzSubscription -SubscriptionName ''

$context = $Sub | Set-AzContext

$rv = Get-AzRecoveryServicesVault -ResourceGroupName '' -Name ''

  Set-AzRecoveryServicesAsrVaultContext -Vault $rv -defaultprofile $context

Steps to reproduce the issue:

Expected behaviour Error output

'.
Set-AzRecoveryServicesAsrVaultContext : Operation failed.
Download vault credential file using cmdlet Get-AzRecoveryServicesVaultSettingsFile and Import-AzRecoveryServicesAsrVaultSettingsFile
At line:1 char:1
+ Set-AzRecoveryServicesAsrVaultContext -Vault $rv -defaultprofile $con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzRecoveryServicesAsrVaultContext], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrVaultSettings

```**DEBUG**
**DEBUG**: AzureQoSEvent: CommandName - Set-AzRecoveryServicesAsrVaultContext; IsSuccess - False; Duration - 00:00:00.0263626; Exception - System.Exception: Operation failed.
Download vault credential file using cmdlet Get-AzRecoveryServicesVaultSettingsFile and Import-AzRecoveryServicesAsrVaultSettingsFile ---> System.Exception: Download vault credential
 file using cmdlet Get-AzRecoveryServicesVaultSettingsFile and Import-AzRecoveryServicesAsrVaultSettingsFile
   at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrVaultSettings.SetARSVaultContext(ARSVault arsVault)
   at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SetAzureRmRecoveryServicesAsrVaultSettings.ExecuteSiteRecoveryCmdlet()
   at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet()
   --- End of inner exception stack trace ---
   at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.HandleException(Exception ex)
   at Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.SiteRecoveryCmdletBase.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 8:28:22 AM - SetAzureRmRecoveryServicesAsrVaultSettings end processing.

**Module in use and version:**

Captured output from `$**PSVersionTable**`:

Name                           Value                                                                                                                                                 
----                           -----                                                                                                                                                 
PSVersion                      5.1.14409.1005                                                                                                                                        
PSEdition                      Desktop                                                                                                                                               
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                               
BuildVersion                   10.0.14409.1005                                                                                                                                       
CLRVersion                     4.0.30319.42000                                                                                                                                       
WSManStackVersion              3.0                                                                                                                                                   
PSRemotingProtocolVersion      2.3                                                                                                                                                   
SerializationVersion           1.1.0.1   

Az Modules ModuleType Version Name ExportedCommands


Script 2.2.5 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}

ModuleType Version Name ExportedCommands


Script 3.4.0 Az.RecoveryServices {Add-AzRecoveryServicesAsrReplicationProtectedItemDisk, Backup-AzRecoveryServicesBackupItem, Copy-AzRecoveryServicesVaul..

BernieWhite commented 3 years ago

@Manvendra11 This doesn't look like it is anything related to PSRule as we don't use Set-AzRecoveryServicesAsrVaultContext at all. Are you able to post additional information for PSRule if this is related?

Are you looking for Azure PowerShell help?

BernieWhite commented 3 years ago

@Manvendra11 I'm going to close this issue because there is not enough information. If you are able to collect some more information please let me know.

For general Azure PowerShell issues see https://github.com/Azure/azure-powershell