Skip to content

Import-KeyVaultCertificate

Azure: Imports a Key Vault certificate

param(
	[Parameter(Mandatory = $true)]
	[string]$VaultName,

	[Parameter(Mandatory = $true)]
	[string]$Name,

	[Parameter(Mandatory = $true)]
	[string]$FilePath
)

try {
	Import-Module Az.KeyVault -ErrorAction Stop
	$cert = Import-AzKeyVaultCertificate -VaultName $VaultName -Name $Name -FilePath $FilePath -ErrorAction Stop
	Write-Output "Successfully imported certificate '$Name' to vault '$VaultName'."
} catch {
	Write-Error $_
	exit 1
}

The name of the Key Vault.

The name for the certificate in the vault.

The path to the certificate file (.pfx or .pem).

An interactive directory of PowerShell scripts.