paolosalvatori/private-aks-cluster

Hidden Carriage Return invalidates ARM template

conradj3 opened this issue · 4 comments

templates/one-node-pool/azuredeploy.json

     Line: 872 "kubernetesVersion": "[parameters('aksClusterKubernetesVersion')]"

templates/two-node-pool/azuredeploy.json

     Line: 1211 "kubernetesVersion": "[parameters('aksClusterKubernetesVersion')]"

When these are passed to Microsoft.ContainerService/managedClusters with apiVersion 2020-11-01 or 2020-09-01 the by:
variable set from .sh

kubernetesVersion=$(az aks get-versions --location $location --query orchestrators[-1].orchestratorVersion --output tsv)
    echo "Validating ["$template"] ARM template..."
    az deployment group validate \
    --resource-group $aksResourceGroup \
    --only-show-errors \
    --template-file $template \
    --parameters $parameters \
    --parameters aksClusterName=$aksName \
    aksClusterKubernetesVersion=$kubernetesVersion

A very odd carriage return in the semantic versioning causes validation to error received by the shell variable to the template

Azure Error: InvalidTemplateDeployment
Message: The template deployment 'azuredeploy' is not valid according to the validation procedure. The tracking id is '0
15f4d0c-ae34-4eb8-b265-0f60913c73f3'. See inner errors for details.
Exception Details:
        Error Code: InternalOperationError
        Message: Provisioning of resource(s) for container service dex in resource group dex-rsg-aks failed. Message: {
  "code": "InternalOperationError",
  "message": "Error to parse agent pool version \"1.19.3\\r\": Invalid character(s) found in patch number \"3\\r\""
 }. Details:

Took a look into this but had to give up for the night, simply passing string values of 1.19.3 moves the template forward through validation until public rsa ssh.

Thanks for the heads up @conradj3. I used these bash scripts several times from WSL 2 (Ubuntu 18.04 LTS) and I never stumbled into this issue. Where did you run the bash scripts? Can you please try to put $kubernetesVersion between double quotes as below and retry? Thanks

    az deployment group validate \
    --resource-group $aksResourceGroup \
    --only-show-errors \
    --template-file $template \
    --parameters $parameters \
    --parameters aksClusterName="$aksName" \
    aksClusterKubernetesVersion="$kubernetesVersion"

Ran both on WSL2 Ubuntu 20.04 / 18.04. Yes I will certainly give it a go. This is awesome work btw! Thank you very much for providing this out to the community.

Thanks @conradj3 😊 please let me if it works, and sorry for the inconvenience 😊

No inconvenience at all. After doing some further investigating azure-cli was at:

{
  "azure-cli": "2.14.0",
  "azure-cli-core": "2.14.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "aks-preview": "0.4.70"
  }
}

After installing azure-cli 2.16.0 it is now working properly.

{
  "azure-cli": "2.16.0",
  "azure-cli-core": "2.16.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "aks-preview": "0.4.70"
  }
}