Search code examples
azureazure-keyvaultazure-cliazure-cli2

Injecting secret into Azure Windows VM at time of provisioning


I'm using Azure CLI for VM deployment. I've secret which is currently stored in Azure Key Vault which I wanted to store it in C drive of the windows VM. I'm not sure how to perform the same at the time of VM deployment

I've found couple of articles which inject password from key vault as VM password using JSON template but i cannot find any article which guides how to store secret from key vault inside the VM at the time of VM provisioning and using Azure CLI.

Note: It is not a certificate but a secret.

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-keyvault-parameter#reference-secrets-with-static-id


Solution

  • in this case you can use customdata property of an Azure VM, for example with an ARM template. you'd need to base64 encode the kubeconfig file. it will be available on the vm under c:\something\customdata (I dont remember exactly at this time)