skip to Main Content

This is concerning the Azure Deployment Template for a MongoDB Replica Set defined here mongodb-replica-set-centos.

When I run the recommended deployment commands to deploy the replica set, namely

az group create --name <resource-group-name> --location <resource-group-location> # Use this command when you need to create a new resource group for your deployment.
az deployment group create --resource-group <my-resource-group> --template-uri https://raw.githubusercontent.com/migr8/AzureDeploymentTemplates/main/mongo/mongodb-replica-set-centos/azuredeploy.json

where the resource group is already set up. I receive the following error:

{
  "status": "Failed",
  "error": {
    "code": "DeploymentFailed",
    "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
    "details": [
      {
        "code": "Conflict",
        "message": "{rn  "status": "Failed",rn  "error": {rn    "code": "ResourceDeploymentFailure",rn    "message": "The resource operation completed with terminal provisioning state 'Failed'.",rn    "details": [rn      {rn        "code": "DeploymentFailed",rn        "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",rn        "details": [rn          {rn            "code": "BadRequest",rn  "message": "{\r\n  \"error\": {\r\n    \"code\": \"InvalidParameter\",\r\n    \"message\": \"The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.\",\r\n    \"target\": \"linuxConfiguration.ssh.publicKeys.keyData\"\r\n  }\r\n}"rn          }rn        ]rn      }rn    ]rn  }rn}"
      },
      {
        "code": "Conflict",
        "message": "{rn  "status": "Failed",rn  "error": {rn    "code": "ResourceDeploymentFailure",rn    "message": "The resource operation completed with terminal provisioning state 'Failed'.",rn    "details": [rn      {rn        "code": "DeploymentFailed",rn        "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",rn        "details": [rn          {rn            "code": "BadRequest",rn            "message": "{\r\n  \"error\": {\r\n    \"code\": \"InvalidParameter\",\r\n    \"message\": \"The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.\",\r\n    \"target\": \"linuxConfiguration.ssh.publicKeys.keyData\"\r\n  }\r\n}"rn          }rn        ]rn      }rn    ]rn  }rn}"
      }
    ]
  }
}

The problem field is in both primary-resources.json and secondary-resources.json appears to be

    "variables": {
        "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('subnet').vnet, parameters('subnet').name)]",
        "securityGroupName": "[concat(parameters('namespace'), parameters('vmbasename'), 'nsg')]",
        "linuxConfiguration": {
            "disablePasswordAuthentication": true,
            "ssh": {
                "publicKeys": [
                    {
                        "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",
                        "keyData": "[parameters('adminPasswordOrKey')]"
                    }
                ]
            }
        }
    },

And ascociated with the variable adminPasswordOrKey. I have tried changing this to be both standard passwords and SSH keys of varying bit-depth, no luck…

How can I fix this?

Repro steps

  1. Run az group create --name <resource-group-name> --location <resource-group-location> where resource group exists.
  2. Run az deployment group create --resource-group <my-resource-group> --template-uri https://raw.githubusercontent.com/migr8/AzureDeploymentTemplates/main/mongo/mongodb-replica-set-centos/azuredeploy.json and step through the prompts
  3. Enter the relevant in formation.

Further Investigation

I have just seen this answer (https://stackoverflow.com/a/60860498/626442) saying specifically that

Note: Please note that the only allowed path is /home//.ssh/authorized_keys due to a limitation of Azure.

I have changed this value of the path, no joy, same error. :'[

2

Answers


  1. You forgot to pass parameters in az deployment group create .... --parameters azuredeploy.parameters.json. You can download azuredeploy.parameters.json and change values as needed. See https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-use-parameter-file?tabs=azure-cli#deploy-template for details.

    Specifically the error in the question complains about adminUsername parameter being empty. Bear in mind this user name is also being used in the home directory path, so limit yourself to lowcase ASCII a-z, numbers, underscore. No spaces, not special characters, no utf.

    Not related to the error, but be aware these necromancers use mongo 3.2 which was buried 4 years ago: https://www.mongodb.com/support-policy/lifecycles. Considering they open it wide to the internet you may have way more problems if you actually deploy it.

    UPDATE

    An example of the parameters I used:

    {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "adminUsername": {
          "value": "yellow"
        },
        "mongoAdminUsername": {
          "value": "phrase"
        },
        "mongoAdminPassword": {
          "value": "settle#SING"
        },
        "secondaryNodeCount": {
          "value": 2
        },
        "sizeOfDataDiskInGB": {
          "value": 2
        },
        "dnsNamePrefix": {
          "value": "written"
        },
        "centOsVersion": {
          "value": "7.7"
        },
        "primaryNodeVmSize": {
          "value": "Standard_D1_v2"
        },
        "secondaryNodeVmSize": {
          "value": "Standard_D1_v2"
        },
        "zabbixServerIPAddress": {
          "value": "Null"
        },
        "adminPasswordOrKey": {
          "value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDdNRTU0XF3xazhhDmwXXWGG7wp4AaQC1r89K7sZFRXp9VSUtydV59DHr67mV5/0DWI5Co1yWK713QJ00BPlBIHNMNLuoBBq8IkOx8fBZF1g9YFm5Zy4ay+CF4WgDITAsyxhKvUWL6jwG5M3XIdVYm49K+EFOCWSSaNtCk8tHhi3v6/5HFkwc2r0UL/WWWbbt5AmpJ8QOCDk/x+XcgCjP9vE5jYYGsFz9F6V1FdOpjVfDwi13Ibivj/w2wOZh2lQGskC+qDjd2upK13+RfWYHY3rr+ulNRPckHRhOqmZ2vlUapO4T0X9mM6ugSh1FprLP5nHdVCUls2yw4BAcSoM9NMiyafE56Xkp9h3bTAfx5Ufpe5mjwQp+j15np1pVpwDaEgk7ZeaPoZPhbalpvZGyg9KiKfs9+KUYHfGklIOHKJ3RUoPE286rg1U4LGswil5RARRSf86kBBHXaIPxy1X0N6QryeWhk0aM6LWEdl7mVbQksa7ilANnsaVMl7FSdY/Cc="
        }
      }
    }
    

    DANGER: It will deploy publicly accessible mongodb replica set with publicly accessible credentials, so please delete the resources as soon as you are happy with testing/debugging

    This is how deployment looks like on the portal: enter image description here

    Login or Signup to reply.
  2. If you’re using the Ed25519 key type, please note that Microsoft Azure does not currently support Ed25519 SSH keys for virtual machines (VMs). The supported SSH key types for VM authentication in Azure are RSA and DSA key types.

    https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/ed25519-ssh-keys

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search