I'm not sure if I am going mad or something has updated but this is the issue:
I am trying to upload private keys into Azure key vault (as secrets) from the Powershell CLI, which I have done many times before without a problem but now it doesn't work.
I start with the command az keyvault secret set --name my-secret-name --vault-name example_name --value ""
and then copy and paste the PEM key from a SQL Server query, which has \r\n
in it and paste it directly between the quotes in Powershell. By splitting the quotes, it is supposed to be permitted to cross multiple lines but what is happening is that as soon as it encounters the first \r\n
, powershell is closing the quote so only the first line is submitted and uploaded to the key vault, the rest of the lines obviously produce syntax errors.
I have tried creating a variable directly like $something = "----BEGIN RSA PRIVATE KEY.."
over several lines and also using the Secure-String
method and both seem to work in that I can then write that back to the console but calling az keyvault secret
passing it the variable instead seems to still break it and only send the first line again.
If I query some older keys, that were all uploaded from Powershell, they correctly contain the line endings which are rendered with az keyvault secret show
as \r\n
so it def should work.