Azure / Azure/azure-powershell

Import-AzWebAppKeyVaultCertificate : Object reference not set to an instance of an object.

Open
#27,239 2 comments 0 reactions 0 assignees View on GitHub
act-observability-squad App Services bug customer-reported Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

when we try to use the command to upload an "uploaded" certificate to another function app located in another region, we encountered this error.

we're experiencing the exact same issue as this bug https://github.com/Azure/azure-powershell/issues/19592 reported by another user about more than 2 years ago but had been closed as fixed.

### Issue script & Debug output

```PowerShell
Import-AzWebAppKeyVaultCertificate -ResourceGroupName "Default-Web-WestUS" -WebAppName "ContosoWebApp" -KeyVaultName "ContosoKeyVault" -CertName "ContosoCertname" -Debug

![Image](https://github.com/user-attachments/assets/243e6620-f2e6-4347-b618-9520d90d02f2)

![Image](https://github.com/user-attachments/assets/f1338945-f5d0-40fb-8da6-3940cc32e6b2)
```

### Environment data

```PowerShell
PS C:\Windows\system32> $PSVersionTable

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

### Module versions

```PowerShell
PS C:\Windows\system32> Get-Module -Name Az.*

ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 4.0.2 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}
Script 3.3.0 Az.Websites {Add-AzWebAppAccessRestrictionRule, Add-AzWebAppTrafficRouting, Edit-AzWebAppBackupConfiguration, Get-AzAppServiceEnvironment...}
```

### Error output

```PowerShell
HistoryId: 7

Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.WebApps.Models.WebApp.PSCertificate..ctor(Certificate other)
at Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.ImportAzWebAppKeyVaultCertificate.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.NullReferenceException
InvocationInfo : {Import-AzWebAppKeyVaultCertificate}
Line : Import-AzWebAppKeyVaultCertificate -ResourceGroupName "wmh-funcapp" -WebAppName "wmhfunc" -KeyVaultName "wmhkeyvault1228" -CertName "apimclientcertttt0608"
Position : At line:1 char:1
+ Import-AzWebAppKeyVaultCertificate -ResourceGroupName "wmh-funcapp" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 7
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.