3
votes

I created a ARM template for automatic AKS creation and/or updates. I generated a RSA public key using the Azure bash command line and entered it in the ARM template. I use the template in an Azure DevOps pipeline. Deployment failes. with the error message:

[error]InvalidParameter: Provisioning of resource(s) for container service aks-openfaas-test-0619 in resource group rg-openfaas--test-0619 failed. Message: {
  "code": "InvalidParameter",
  "message": "The value of parameter linuxProfile.ssh.publicKeys.keyData is invalid. Please see https://aka.ms/aks-naming-rules for more details.",
  "target": "linuxProfile.ssh.publicKeys.keyData"
 }. Details:  undefined

I followed the Microsoft instruction on https://docs.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys.

What am I doing wrong?

2
Please add more information to help with reproducibility for others. You might follow this GitHub issue addressing a similar error message. Chances are you are facing a similar problem.Sascha Gottfried
Does it work when you deploy from New-AzResourceGroupDeployment ? I've got the same problem if it does...Elomis

2 Answers

0
votes

I had this error when trying to use in AKS node pools.

Add \n at the end. The content of the pub file was like below, replace windowsuser@computername with \n in the json.

ssh-rsa ***Key*** windowsuser@computername
"linuxProfile": {
                    "adminUsername": "azureuser",
                    "ssh": {
                      "publicKeys": [
                        {
                            "keyData": "ssh-rsa *****Key*****\n"
                        }
                      ]
                    }
                  }
0
votes

I had the same error when trying to create new VMs using Azure templates

in my case I had to add a few more \n not only one at the end of the key.

If you have a Public SSH key in a format like this:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20200611"
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF==
---- END SSH2 PUBLIC KEY ----

Once you copy and paste this into the template field: Admin Public Key * :

I finally got it working if you replace at least four new lines with \n and remove any extra spaces inside the random generated key.

---- BEGIN SSH2 PUBLIC KEY ----\nComment: \"rsa-key-20200611\"\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF==\n---- END SSH2 PUBLIC KEY ----\n

Another other option is, if you want to keep it exactly following same format, then you can replace any space character ' ' inside the key for '\n' as well.

Once you do this the format of the key will be correct and you will get the VMs properly created using templates. That is a common copy paste problem replacing new line characters for just a regular space character.