Azure certificate assign to vm

I am trying to add a certificate stored in the Key Vault on a VM machine but I am not able to, does anyone know how to do it?

I would like you to help me solve this problem.

1 answer

  • answered 2018-01-16 12:44 Sumanth BM

    # Install a secret stored in KeyVault into an Azure VM's credential store.
    $resourceGroup = [resource group name]
    $vm = Get-AzureRmVM -ResourceGroupName $resourceGroup -Name [VM name]
    $vaultId = "/subscriptions/[subscription guid]/resourceGroups/$resourceGroup/providers/Microsoft.KeyVault/vaults/[vault name]"
    $certStore = "My"
    $certUrl = [KeyVault secret URL w/ version id]
    $vm = Add-AzureRmVMSecret -VM $vm -SourceVaultId $vaultId -CertificateStore $certStore -CertificateUrl $certUrl
    # Update the VM so the changes take effect.
    Update-AzureRmVM -ResourceGroupName $resourceGroup -VM $vm

    server {
        listen 80;
        return 301 https://$host$request_uri;
    server {
        listen 443;
        ssl_certificate           /etc/nginx/ssl/cert.pem;
        ssl_certificate_key       /etc/nginx/ssl/key.key;
        ssl on;
        ssl_session_cache  builtin:1000  shared:SSL:10m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_prefer_server_ciphers on;
        access_log            /var/log/nginx/jenkins.access.log;
        location / {
          proxy_set_header        Host $host;
          proxy_set_header        X-Real-IP $remote_addr;
          proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header        X-Forwarded-Proto $scheme;
          # Fix the “It appears that your reverse proxy set up is broken" error.
          proxy_pass          http://localhost:8000;
          proxy_read_timeout  90;
          proxy_redirect      http://localhost:8000;

    For more information refer to this article Deploy Certificates to VMs from customer-managed Key Vault

    Additional information: Configure App Service Certificate to Azure Virtual machine with Windows or Linux OS