Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

`Get-AzKeyVaultCertificatePolicy` persistently fails with `Value cannot be null` #22642

Closed StrawnSC closed 1 year ago

StrawnSC commented 1 year ago

Description

Get-AzKeyVaultCertificatePolicy -VaultName <> -Name <> persistently fails with Get-AzKeyVaultCertificatePolicy : Value cannot be null. Parameter name: collection. As far as I can tell, there is no parameter on the command called "collection" and the correct usage is to just pass in vault name and name. Seems like there's a bug in the cmdlet

I've tried updating to the latest version of the az module and it didn't help. Based on the debug logs, the API returns the policy correctly but something goes wrong after that

Issue script & Debug output

PS C:\Users\sstrawn> Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test"
DEBUG: 1:17:49 PM - GetAzureKeyVaultCertificatePolicy begin processing with ParameterSet 'VaultAndCertName'.
DEBUG: 1:17:49 PM - using account id '[redacted]@microsoft.com'...
DEBUG: [Common.Authentication]: Authenticating using Account: '[redacted]@microsoft.com', environment: 'AzureCloud', tenant:
'[redacted]'
DEBUG: 1:17:49 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'[redacted]',
Scopes:'https://vault.azure.net/.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[redacted]@microsoft.com'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://vault.azure.net/.default ] ParentRequestId:
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] Azure region was not configured or could not be discovered. Not using a
regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49] Found 1 cache accounts and 0 broker accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49] Returning 1 accounts
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] MSAL MSAL.Desktop with assembly version '4.30.1.0'.
CorrelationId(1bac133b-9ffc-4dcd-8380-2ee8541e72e2)
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] === AcquireTokenSilent Parameters ===
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] LoginHint provided: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] Account provided: True
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] ForceRefresh: False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ]
=== Request Data ===
Authority Provided? - True
Scopes - https://vault.azure.net/.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 1bac133b-9ffc-4dcd-8380-2ee8541e72e2
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] === Token Acquisition (SilentRequest) started:

 Authority Host: login.microsoftonline.com
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] Azure region was not configured or could not be discovered. Not using a
regional authority.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] Access token is not expired. Returning the found cache entry. [Current
time (08/23/2023 20:17:49) - Expiration Time (08/23/2023 21:10:10 +00:00) - Extended Expiration Time (08/23/2023 21:10:10 +00:00)]
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] Returning access token found in cache. RefreshOn exists ? False
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] Fetched access token from host login.microsoftonline.com.
DEBUG: (False) MSAL 4.30.1.0 MSAL.Desktop Windows 10 Enterprise [08/23/2023 20:17:49 - ] === Token Acquisition finished successfully. An access token was
returned with Expiration Time: 08/23/2023 21:10:10 +00:00 and Scopes https://vault.azure.net/user_impersonation https://vault.azure.net/.default
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://vault.azure.net/.default ] ParentRequestId:  ExpiresOn: 2023-08-23T21:10:10.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '[redacted]', UserId: '[redacted]@microsoft.com'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://cnd-kv.vault.azure.net//certificates/renewal-test/policy?api-version=7.0

Headers:
x-ms-client-request-id        : 66ae418c-5850-4d19-8293-2fc294174eee
accept-language               : en-US

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-keyvault-region          : eastus
x-ms-client-request-id        : 66ae418c-5850-4d19-8293-2fc294174eee
x-ms-request-id               : 9cd19986-1a51-4436-a10a-050a6da2c6c5
x-ms-keyvault-service-version : 1.9.950.1
x-ms-keyvault-network-info    : conn_type=Ipv4;addr=104.232.118.174;act_addr_fam=InterNetwork;
X-Content-Type-Options        : nosniff
Strict-Transport-Security     : max-age=31536000;includeSubDomains
Cache-Control                 : no-cache
Date                          : Wed, 23 Aug 2023 20:17:49 GMT

Body:
{
  "id": "https://cnd-kv.vault.azure.net/certificates/renewal-test/policy",
  "key_props": {
    "exportable": true,
    "kty": "RSA",
    "key_size": 2048,
    "reuse_key": false
  },
  "secret_props": {
    "contentType": "application/x-pkcs12"
  },
  "x509_props": {
    "subject": "CN=[redacted].com",
    "sans": {},
    "ekus": [
      "[redacted]",
      "[redacted]"
    ],
    "key_usage": [
      "digitalSignature",
      "keyEncipherment"
    ],
    "validity_months": 1,
    "basic_constraints": {
      "ca": false
    }
  },
  "lifetime_actions": [
    {
      "trigger": {
        "lifetime_percentage": 1
      },
      "action": {
        "action_type": "EmailContacts"
      }
    }
  ],
  "issuer": {
    "name": "Self"
  },
  "attributes": {
    "enabled": true,
    "created": 1691606455,
    "updated": 1692739120
  }
}

Get-AzKeyVaultCertificatePolicy : Value cannot be null.
Parameter name: collection
At line:1 char:1
+ Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzKeyVaultCertificatePolicy], ArgumentNullException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy

DEBUG: AzureQoSEvent: Module: Az.KeyVault:3.6.0; CommandName: Get-AzKeyVaultCertificatePolicy; PSVersion: 5.1.22621.1778; IsSuccess: False; Duration:
00:00:00.5132950; Exception: Value cannot be null.
Parameter name: collection;
DEBUG: Finish sending metric.
DEBUG: 1:17:49 PM - GetAzureKeyVaultCertificatePolicy end processing.

Environment data

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

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.5.4      Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script     3.6.0      Az.KeyVault                         {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateContact, Add-AzKeyVaultKey, Add-AzKeyVaultManag...

Error output

DEBUG: 1:23:52 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 1:23:52 PM - using account id 'silasstrawn@microsoft.com'...
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
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: 29

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 29

   HistoryId: 27

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 27

   HistoryId: 26

Message        : A positional parameter cannot be found that accepts argument 'd'.
StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements,
                 CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy d -VaultName "cnd-kv" -Name "renewal-test"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy d -VaultName "cnd-kv" -Name "renewal- ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 26

   HistoryId: 25

Message        : A positional parameter cannot be found that accepts argument '--collection'.
StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements,
                 CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test" --collection
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 25

   HistoryId: 24

Message        : A positional parameter cannot be found that accepts argument '--collection'.
StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements,
                 CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test" --collection "poo"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 24

   HistoryId: 23

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 23

   HistoryId: 18

Message        : Administrator rights are required to install modules in 'C:\Program Files\WindowsPowerShell\Modules'. Log on to the computer with an account
                 that has Administrator rights, and then try again, or install 'C:\Users\sstrawn\Documents\WindowsPowerShell\Modules' by adding "-Scope
                 CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).
StackTrace     :    at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
Exception      : System.ArgumentException
InvocationInfo : {Install-Module}
Line           : Install-Module -Name Az
Position       : At line:1 char:1
                 + Install-Module -Name Az
                 + ~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 18

   HistoryId: -1

Message        : Unable to find type [Microsoft.PowerShell.Commands.PowerShellGet.Telemetry].
StackTrace     :    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line           :     $telemetryMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | Get-Member -Static).Name

Position       : At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:715 char:26
                 + ... yMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | ...
                 +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : -1

   HistoryId: 14

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 14

   HistoryId: 11

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 11

   HistoryId: 10

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName cnd-kv -Name renewal-test
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName cnd-kv -Name renewal-test
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 10

   HistoryId: 8

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName cnd-kv -Name renewal-test
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName cnd-kv -Name renewal-test
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 8

   HistoryId: 7

Message        : Value cannot be null.
                 Parameter name: collection
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
                    at Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultCertificatePolicy.FromCertificatePolicy(CertificatePolicy certificatePolicy)
                    at Microsoft.Azure.Commands.KeyVault.Models.KeyVaultDataServiceClient.GetCertificatePolicy(String vaultName, String certificateName)
                    at Microsoft.Azure.Commands.KeyVault.Commands.GetAzureKeyVaultCertificatePolicy.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.ArgumentNullException
InvocationInfo : {Get-AzKeyVaultCertificatePolicy}
Line           : Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-test"
Position       : At line:1 char:1
                 + Get-AzKeyVaultCertificatePolicy -VaultName "cnd-kv" -Name "renewal-te ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 7

   HistoryId: 4

Message        : A parameter cannot be found that matches parameter name 'h'.
StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException originalBindingException)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
                    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
                    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
                    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
                    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements,
                 CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Add-AzKeyVaultCertificate}
Line           : Add-AzKeyVaultCertificate -h
Position       : At line:1 char:27
                 + Add-AzKeyVaultCertificate -h
                 +                           ~~
HistoryId      : 4

   HistoryId: 1

Message        : Cannot process command because of one or more missing mandatory parameters: VaultName Name CertificatePolicy.
StackTrace     :    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                    at System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
Exception      : System.Management.Automation.ParameterBindingException
InvocationInfo : {Add-AzKeyVaultCertificate}
Line           : Add-AzKeyVaultCertificate
Position       : At line:1 char:1
                 + Add-AzKeyVaultCertificate
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.

DEBUG: AzureQoSEvent: Module: Az.Accounts:2.5.4; CommandName: Resolve-AzError; PSVersion: 5.1.22621.1778; IsSuccess: True; Duration: 00:00:00.1042083
DEBUG: Finish sending metric.
DEBUG: 1:23:53 PM - ResolveError end processing.
isra-fel commented 1 year ago

@BethanyZhou hey could you look into this issue? Thanks.

BethanyZhou commented 1 year ago

@StrawnSC thanks for reporting this issue. Please expect this issue fixed on 4.11.0 (available on Sep 5).

StrawnSC commented 1 year ago

Thanks for the quick turnaround @BethanyZhou! Appreciate the help