Galet
Galet

Reputation: 6299

How to list IP of Azure VM or HDI cluster after deployment using ARM template in the output

I have created ARM template to deploy Azure VM and HDI cluster. I want to get and list the Public IP of Azure VM and Private IP of HDI cluster headnode after deployment is finished.

Is there a way to get it using ARM template?

Upvotes: 0

Views: 912

Answers (2)

rahuljain1311
rahuljain1311

Reputation: 2160

The above solution is good with respect to the question asked. But, ideally you should not use the Private IP of HDI cluster headnode. This is because the private IP will change in case the head node (VM over which it is running) goes down. There is a concept of FQDN (Fully Qualified Domain Name) of the head nodes, something like: hn0-van.0owcbllr5hze3hxdja3mqlrhhe.ex.internal.cloudapp.net and hn1-van.0owcbllr5hze3hxdja3mqlrhhe.ex.internal.cloudapp.net. Use these FQDN in place of IP address everywhere. Their DNS resolution is automatically handled by Azure vnet default DNS resolver. So no worries there.

Get FQDN: az network nic list --resource-group <RESOURCEGROUP>

Replace the with your resource group name. Check the FQDN setting of the headnode.

Once I get time, I will post the PowerShell script as well to get the exact FQDN for directly the head node.

Reference: https://learn.microsoft.com/en-us/azure/hdinsight/hdinsight-plan-virtual-network-deployment#multinet

Upvotes: 0

Shui shengbao
Shui shengbao

Reputation: 19225

Is there a way to get it using ARM template?

Based on my knowledge, you could not get VM IP with template.You could use azure cli to get your VM IP instead of template. If your cli on Linux, you could use the following command after you create your VM.

azure vm show -g shui123 -n shui|grep "Public IP address"| awk -F: '{print $3}'

I want to get and list the Public IP of Azure VM and Private IP of HDI cluster headnode after deployment is finished.

Public IP of Azure VM do you mean? Just VM or VM in HDI cluster?

If it is just a VM, you could use the command above, if it is VM in HDI cluster, Azure HDInsight cluster will not allow any public IP to be assigned to it. if you need a IP to be allocated to HDInsight cluster, you would have to create HDInsight in a VNET. the following article does talk about this.

You could get HDI cluster IP with ​Ambari ​RE​ST ​AP​I.

for HOSTNAME in $(curl -u admin:$PASSWORD -sS -G "https://shuitest.azurehdinsight.net/api/v1/clusters/shuitest/hosts" | jq -r '.items[].Hosts.host_name')
do
    IP=$(curl -u admin:$PASSWORD -sS -G "https://$CLUSTERNAME.azurehdinsight.net/api/v1/clusters/$CLUSTERNAME/hosts/$HOSTNAME" | jq -r '.Hosts.ip')
  echo "$HOSTNAME <--> $IP"
done

More information about Ambari ​RE​ST ​AP​I please refer to this link.

Update:

If you only want to list active node IP, you could use the following commands.

PASSWORD=
CLUSTERNAME=

curl -u admin:$PASSWORD -sS -G "https://$CLUSTERNAME.azurehdinsight.net/api/v1/clusters/$CLUSTERNAME/services/HDFS/components/NAMENODE" |grep LiveNode>test.txt

cat test.txt |awk -F'\' '{print $2}'|sed 's/\"//g'|tail -1|awk -F: '{print $1}'

Upvotes: 2

Related Questions