Base URI for Ambari Rest API

The base URI for the Ambari REST API on HDInsight is https://CLUSTERNAME.azurehdinsight.net/api/v1/clusters/CLUSTERNAME, where CLUSTERNAME is the name of your cluster. Cluster names in URIs are case-sensitive. While the cluster name in the fully qualified domain name (FQDN) part of the URI (CLUSTERNAME.azurehdinsight.net) is case-insensitive, other occurrences in the URI are case-sensitive.

Authentication

Connecting to Ambari on HDInsight requires HTTPS. Use the admin account name (the default is admin) and password you provided during cluster creation.

Examples

Setup (Preserve credentials)

Preserve your credentials to avoid reentering them for each example. The cluster name will be preserved in a separate step.

Identify correctly cased cluster name

The actual casing of the cluster name may be different than you expect depending on how the cluster was created. The steps here will show the actual casing, and then store it in a variable for all subsequent examples.

Edit the scripts below to replace CLUSTERNAME with your cluster name. Then enter the command. (The cluster name for the FQDN is not case-sensitive.)

Get the FQDN of cluster nodes

When working with HDInsight, you may need to know the fully qualified domain name (FQDN) of a cluster node. You can easily retrieve the FQDN for the various nodes in the cluster using the following examples:

To find the IP address, you must know the internal fully qualified domain name (FQDN) of the cluster nodes. Once you have the FQDN, you can then get the IP address of the host. The following examples first query Ambari for the FQDN of all the host nodes, then query Ambari for the IP address of each host.

Get the default storage

When you create an HDInsight cluster, you must use an Azure Storage Account or Data Lake Storage as the default storage for the cluster. You can use Ambari to retrieve this information after the cluster has been created. For example, if you want to read/write data to the container outside HDInsight.

The following examples retrieve the default storage configuration from the cluster:

These examples return the first configuration applied to the server (service_config_version=1) which contains this information. If you retrieve a value that has been modified after cluster creation, you may need to list the configuration versions and retrieve the latest one.

The return value is similar to one of the following examples:

wasb://CONTAINER@ACCOUNTNAME.blob.core.windows.net - This value indicates that the cluster is using an Azure Storage account for default storage. The ACCOUNTNAME value is the name of the storage account. The CONTAINER portion is the name of the blob container in the storage account. The container is the root of the HDFS compatible storage for the cluster.

abfs://CONTAINER@ACCOUNTNAME.dfs.core.windows.net - This value indicates that the cluster is using Azure Data Lake Storage Gen2 for default storage. The ACCOUNTNAME and CONTAINER values have the same meanings as for Azure Storage mentioned previously.

adl://home - This value indicates that the cluster is using Azure Data Lake Storage Gen1 for default storage.

To find the Data Lake Storage account name, use the following examples:

This example returns a JSON document containing the current configuration (identified by the tag value) for the components installed on the cluster. The following example is an excerpt from the data returned from a Spark cluster type.

Edit newconfig.json.
Open the newconfig.json document and modify/add values in the properties object. The following example changes the value of "livy.server.csrf_protection.enabled" from "true" to "false".

"livy.server.csrf_protection.enabled": "false",

Save the file once you are done making modifications.

Submit newconfig.json.
Use the following commands to submit the updated configuration to Ambari.

These commands submit the contents of the newconfig.json file to the cluster as the new desired configuration. The request returns a JSON document. The versionTag element in this document should match the version you submitted, and the configs object contains the configuration changes you requested.

Restart a service component

At this point, if you look at the Ambari web UI, the Spark service indicates that it needs to be restarted before the new configuration can take effect. Use the following steps to restart the service.