Share via

Cannot set up Azure Key Vault extension on Ubuntu VM

David Kelly 20 Reputation points
2026-04-07T11:06:26.3066667+00:00

I am attempting to set up the Azure Key Vault extension on an Azure VM running Ubuntu, so that nginx on that VM can access an SSL certificate with HSM-secured key to secure a website hosted on the VM. However, when running the command below, I get an error message that the secret is not properly Base64 encoded. What am I doing wrong?

az vm extension set -n "KeyVaultForLinux" --publisher Microsoft.Azure.KeyVault -g "{resource-group}" --vm-name "{vm-name}" --version 3.0 --enable-auto-upgrade true --settings "akvm.json"

The error message is:

(CertificateImproperlyFormatted) The secret retrieved from {URL} is not a properly encoded Base64 string.
Azure Key Vault
Azure Key Vault

An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.

0 comments No comments

Answer accepted by question author
  1. Himanshu Shekhar 5,240 Reputation points Microsoft External Staff Moderator
    2026-04-07T16:52:56.8933333+00:00

    The KeyVaultForLinux extension expects a Base64‑encoded PFX certificate stored as a Key Vault Certificate. The error occurs because the referenced secret contains a PEM or non‑Base64 value; importing the certificate as a PFX into Key Vault resolves the issue. Here you are pointing the extension to a secret that is not a PFX-backed Key Vault certificate (for example, a PEM certificate or raw text secret). The extension does not support PEM-only or manually stored secrets for certificate installation - https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/key-vault-linux

    Correct approach

    • Convert the certificate (and private key) into a PFX file
    • Import it into Azure Key Vault as a Certificate (not just a secret)
    • Then reference that certificate in the KeyVaultForLinux extension settings

    Microsoft documentation

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.