从Azure密钥保管库将SSL证书添加到现有VM linux vm [英] Add SSL Cert to an existing VM linux vm from Azure key vault

查看:140
本文介绍了从Azure密钥保管库将SSL证书添加到现有VM linux vm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从Azure Key保管库向现有的Azure Linux虚拟机添加SSL证书.对于Windows,我们使用以下命令

How you add SSL Cert to an existing azure Linux VM from Azure Key vault. for windows we use the following command

$vaultId=(Get-AzureRmKeyVault -ResourceGroupName $resourceGroup -VaultName $keyVaultName).ResourceId
$vm = Add-AzureRmVMSecret -VM $vm -SourceVaultId $vaultId -CertificateStore "My" -CertificateUrl $certURL

对于Linux vm,是否有类似的代码?对于Linux 在Azure的Windows虚拟机上使用SSL证书保护IIS Web服务器

Is there a similar one like this for linux vm? Is there a link similar to this for linux Secure IIS web server with SSL certificates on a Windows virtual machine in Azure

推荐答案

您可以使用Azure Cli执行此操作.使用以下命令.

You could use Azure Cli to do this. Using following command.

secret=$(az keyvault secret list-versions \
          --vault-name $keyvault_name \
          --name mycert \
          --query "[?attributes.enabled].id" --output tsv)
vm_secret=$(az vm format-secret --secret "$secret")

az vm update -n shui -g shuikeyvault --set osProfile.secrets="$vm_secret"

然后将证书存储在/var/lib/waagent上,您可以使用Azure自定义脚本来使用它.

Then the certificate stores on /var/lib/waagent, you could use Azure Custom Script to use it.

注意:您应该使用"$vm_secret",我在实验室中进行了测试,只有$vm_secret对我不起作用.

Note: You should use "$vm_secret", I test in my lab, only $vm_secret does not work for me.

这篇关于从Azure密钥保管库将SSL证书添加到现有VM linux vm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆