Ramji
Ramji

Reputation: 385

Alternative to Import-AzWebAppKeyVaultCertificate in Azure Rm

Planning to import an SSL certificate to a web app from Key Vault.

Found that Import-AzWebAppKeyVaultCertificate in Az.websites which performs the above task but the above fails in the azure pipeline and I'm looking into any alternative in AzureRm As for my research I can't find anything in documents.

Az docs - https://learn.microsoft.com/en-us/powershell/module/az.websites/import-azwebappkeyvaultcertificate?view=azps-6.0.0&viewFallbackFrom=azps-4.8.0

I want to know anything specific command to import ssl certificate to a web app from keyvault using AzureRm commands

Upvotes: 1

Views: 485

Answers (2)

Joy Wang
Joy Wang

Reputation: 42043

You could use Invoke-RestMethod to call the REST API Certificates - Create Or Update manually.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/certificates/{name}?api-version=2019-08-01

To get the access token, refer to https://learn.microsoft.com/en-us/rest/api/azure/#client-credentials-grant-non-interactive-clients

Upvotes: 0

Sajeetharan
Sajeetharan

Reputation: 222532

Did you try with Azure CLI command ?

az login

# upload certificate to Azure key vault
az keyvault certificate import --file "E:\Cert\P2SChildCert.pfx" --password "" --name "test1234" --vault-name "testkey08"

# download certificate as pfx file
az keyvault secret download --file "test2.pfx" --vault-name "testkey08" --name "test1234" --encoding base64

# upload the pfx file to Azue web app
az webapp config ssl upload --certificate-file "test2.pfx"  --name "andywebsite" --resource-group "andywebbot"  --certificate-password "" --query thumbprint --output tsv

Upvotes: 1

Related Questions