Get-AzRecoveryServicesVaultSettingsFile: X509Certificate is immutable on this platform. Use the equivalent constructor instead.
Description
Get-AzRecoveryServicesVaultSettingsFile cmdlet does not work even after providing '-certificate' parameter.
Steps to reproduce
Import AZ module and run the cmdlet Get-AzRecoveryServicesVaultSettingsFile providing the required parameters.
Environment data
Name Value
PSVersion 7.1.0-preview.4 PSEdition Core GitCommitId 7.1.0-preview.4 OS Microsoft Windows 10.0.18362 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
Module versions
PS C:\Study\Git-HubRepository> Get-Module -ListAvailable -Name az
Directory: C:\Users\n****
ModuleType Version PreRelease Name PSEdition ExportedCommands
Script 4.4.0 Az Core,Desk
Debug output
PS C:\Study\Git-HubRepository> $VaultFile = Get-AzRecoveryServicesVaultSettingsFile -SiteRecovery -Vault $vault -Certificate $certficate.ToString()
DEBUG: 9:13:34 PM - GetAzureRmRecoveryServicesVaultSettingsFile begin processing with ParameterSet 'ByDefaultWithCertificate'.
DEBUG: 9:13:34 PM - using account id '***********'...
DEBUG: RecoveryService - Going to upload the certificate
Get-AzRecoveryServicesVaultSettingsFile: X509Certificate is immutable on this platform. Use the equivalent constructor instead.
DEBUG: AzureQoSEvent: CommandName - Get-AzRecoveryServicesVaultSettingsFile; IsSuccess - False; Duration - 00:00:00.0661880;; Exception - System.PlatformNotSupportedException: X509Certificate is immutable on this platform. Use the equivalent constructor instead.
at Microsoft.Azure.Commands.RecoveryServices.GetAzureRmRecoveryServicesVaultSettingsFile.GetSiteRecoveryCredentialsWithCertificate(String certificate)
at Microsoft.Azure.Commands.RecoveryServices.GetAzureRmRecoveryServicesVaultSettingsFile.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__31.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 9:13:35 PM - GetAzureRmRecoveryServicesVaultSettingsFile end processing.
Error output
PS C:\Study\Git-HubRepository> Resolve-AzError -Last
DEBUG: 9:14:05 PM - ResolveError begin processing with ParameterSet 'LastErrorParameterSet'.
DEBUG: 9:14:05 PM - using account id '***********'...
WARNING: Breaking changes in the cmdlet 'Resolve-AzError' :
WARNING: - The Resolve-Error alias will be removed in a future release. Please change any scripts that use this alias to use Resolve-AzError instead.
WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
HistoryId: 191
Message : X509Certificate is immutable on this platform. Use the equivalent constructor instead.
StackTrace : at Microsoft.Azure.Commands.RecoveryServices.GetAzureRmRecoveryServicesVaultSettingsFile.GetSiteRecoveryCredentialsWit
hCertificate(String certificate)
at Microsoft.Azure.Commands.RecoveryServices.GetAzureRmRecoveryServicesVaultSettingsFile.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__31.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet,
Action1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.PlatformNotSupportedException
InvocationInfo : {Get-AzRecoveryServicesVaultSettingsFile}
Line : $VaultFile = Get-AzRecoveryServicesVaultSettingsFile -SiteRecovery -Vault $vault -Certificate $certficate.ToString()
Position : At line:1 char:14
+ … VaultFile = Get-AzRecoveryServicesVaultSettingsFile -SiteRecovery -Va …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 191
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
DEBUG: AzureQoSEvent: CommandName - Resolve-AzError; IsSuccess - True; Duration - 00:00:00.1249092; DEBUG: Finish sending metric. DEBUG: 9:14:06 PM - ResolveError end processing.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Rajeswari-Mamilla.
RecoveryServices team, please help to look into this question.
@Sharmistha-Rai please review
We are tracking this in our backlog items and have logged a bug for this, sometime in Q4 CY 2020. Bug: https://msazure.visualstudio.com/One/_workitems/edit/7904782
Please feel free to reopen for any additional queries.
Do you have any update to fix this problem? the instructions provided here are failing with the error "Get-AzRecoveryServicesVaultSettingsFile: X509Certificate is immutable on this platform. Use the equivalent constructor instead."
@mdurini
This bug is fixed in Az 3.5.0 release. Use Az 3.5.0 or greater version. We need to use the following set of cmdlets to generate vault file using PowerShell -
$dt = $(Get-Date).ToString("M-d-yyyy")
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -FriendlyName 'test-vaultcredentials' -subject "Windows Azure Tools" -KeyExportPolicy Exportable -NotAfter $(Get-Date).AddHours(48) -NotBefore $(Get-Date).AddHours(-24) -KeyProtection None -KeyUsage None -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") -Provider "Microsoft Enhanced Cryptographic Provider v1.0"
$certficate = [convert]::ToBase64String($cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx))
$CredsFilename = Get-AzRecoveryServicesVaultSettingsFile -Vault $Vault -Path $CredsPath -Certificate $certficate
Thank you @Sharmistha-Rai for the solution. it should be mentioned in the official documentation of the command, where the -certificate parameter is not documented at all. Best regards.
@mdurini - Thanks for this suggestion. We're in the process of editing the doc to update both the command and the description for the same.
hi @Sharmistha-Rai I realized that the command Get-AzRecoveryServicesVaultSettingsFile is not working in powershell 7.1.1 x64: i'm gettint the error "X509Certificate is immutable on this platform. Use the equivalent constructor instead.". how is it possible?
Hi @mdurini - let me confirm this issue with my team. Reopening the ticket so that we can troubleshoot.
@mdurini - you have mentioned the PowerShell version. Could you also confirm the version of your Az module? Here is the link to install Az 3.5.0 and here is the link to check your current Az module version.
Also, please use Windows PowerShell and not PowerShell Core, as that may be causing this issue.
Hello, i'm using the AZ module version 5.4.0
Got it, please use Windows PowerShell and not PowerShell Core, as that may be causing this issue.
Yes I saw that in Windows Powershell everything is working. Core it's easier because I can use newest features like the JSONconversion to hashtable. it's not a show stopper searching in google I found that the problem seems to be related to the X509 object type https://www.cloudnotes.io/x509certificate-is-immutable-on-this-platform-use-the-equivalent-constructor-instead/
Okay - so using the solution suggested in the blog post, is it working fine then?
I can't understand how to use the new command to generate the base64 version of the self-signed certificate.
@mdurini - it will be better to use Windows PowerShell only. This is one known issues in the Core version.
We have a requirement to use this in PowerShell core, is there an ETA on a fix for this?