Azure / Azure/azure-powershell

[Doc]: Get-AzKeyVaultCertificate doesn't work well in example command

Open
#27,197 4 comments 0 reactions 1 assignee Claimed by @notyashhh View on GitHub
act-identity-squad Azure PS Team customer-reported Investigate :mag: KeyVault
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Type of issue

Other (describe below)

### Feedback

With commands provided in link below, it doesn't work well:
https://learn.microsoft.com/en-us/powershell/module/az.network/add-azapplicationgatewaysslcertificate?view=azps-13.2.0#example-2-add-an-ssl-certificate-using-keyvault-secret-(version-less-secretid)-to-an-application-gateway

Example 2 commands:
$AppGW = Get-AzApplicationGateway -Name "ApplicationGateway01" -ResourceGroupName "ResourceGroup01"
$secret = Get-AzKeyVaultCertificate -VaultName "keyvault01" -Name "sslCert01"
$secretId = $secret.Id.Replace($secret.Version, "") # https://.vault.azure.net/secrets/
$AppGW = Add-AzApplicationGatewaySslCertificate -ApplicationGateway $AppGW -Name "Cert01" -KeyVaultSecretId $secretId

got error below when running in cloud shell:

Set-AzApplicationGateway: SecretId 'xxx' specified in 'xxx’ is invalid. Reason: The specified Key Vault URI doesn't properly reference a secret. A valid Key Vault URI should be in the following format: [https://{keyvaultname}.{keyvaultdomain}/secrets/{secretname}](https://{keyvaultname}.{keyvaultdomain}/secrets/%7bsecretname%7d). A secret version may optionally be appended as well.

Then we tried command mentioned in link below which using command Get-AzKeyVaultSecrect, it works well:
https://learn.microsoft.com/en-us/azure/application-gateway/key-vault-certs?WT.mc_id=Portal-Microsoft_Azure_HybridNetworking#key-vault-azure-role-based-access-control-permission-model

It looks like Get-AzKeyVaultCertificate command doesn't work to upload cert from keyvault to appgw. Please help to confirm and update public document accordingly.

### Page URL

https://learn.microsoft.com/en-us/powershell/module/az.network/add-azapplicationgatewaysslcertificate?view=azps-13.2.0

### Content source URL

https://github.com/Azure/azure-powershell/blob/main/src/Network/Network/help/Add-AzApplicationGatewaySslCertificate.md

### Author

@mikefrobbins

### Document Id

d9014bc0-dbaa-ad6f-bb29-f30fe3c2a3bd

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.