具有 Microsoft Entra ID 的 HDInsight 集群可以以编程方式通过 Azure REST API 进行管理。 REST API 允许授权客户端执行管理作,例如预配、更新、缩放和删除群集。 此方法非常适合企业自动化方案、与 CI/CD 管道的集成,以及需要精确控制的环境,而无需依赖 Azure 门户或 SDK。
创建
在指定的订阅中创建已启用 Entra 的群集。
请求
有关群集使用的标头和参数,请参阅 通用参数和标头 。
以下示例演示用于创建已启用 Entra 的基于 Linux 的 hadoop 群集的请求正文。 有关以其他方式创建群集的示例,请参阅“示例”部分,如下所示:
{
"id":"/subscriptions/{subscription-id}/resourceGroups/myresourcegroup1/providers/Microsoft.HDInsight/clusters/mycluster",
"name":"mycluster",
"type":"Microsoft.HDInsight/clusters",
"location": "location-name",
"tags": { "tag1": "value1", "tag2": "value2" },
"properties": {
"clusterVersion": "5.1",
"osType": "Linux",
"provisioningState": "InProgress",
"clusterState": "Accepted",
"createdDate": "2015-09-23",
"quotaInfo": {
"coresUsed": 20
}
"clusterDefinition": {
"kind": "hadoop"
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
}
},
{
"name": "workernode",
"targetInstanceCount": 1,
"hardwareProfile": {
"vmSize": "Large"
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
}
}
]
}
}
}
| 元素名称 |
必需 |
类型 |
Description |
| ID |
是 |
String |
指定群集的资源标识符。 |
| name |
是 |
String |
指定群集的名称。 |
| 类型 |
是 |
String |
指定群集的类型。 |
| 位置 |
是 |
String |
指定应在其中创建群集的受支持 Azure 位置。 有关详细信息,请参阅 列出所有可用的地理位置。 |
| tags |
否 |
String |
指定要分配给群集的标记。 有关使用标记的详细信息,请参阅 使用标记来组织 Azure 资源。 |
| 属性 |
是 |
复杂类型 |
指定群集的属性。 |
属性
| 元素名称 |
必需 |
类型 |
Description |
| clusterVersion |
是 |
String |
指定群集版本。 |
| osType |
是 |
String |
指定群集的操作系统。 有效值为 Linux 和 Windows。 |
| clusterDefinition |
是 |
复杂类型 |
指定有关群集类型和配置的信息。 |
| computeProfile |
是 |
复杂类型 |
指定有关群集拓扑和关联角色属性的信息。 |
clusterDefinition
| 元素名称 |
必需 |
类型 |
Description |
| 元素名称 |
必需 |
类型 |
Description |
| kind |
是 |
String |
指定群集类型。 有效值为 hadoop、hbase、storm 和 spark。 |
| configurations |
是 |
字典 |
配置类型与其对应值的字典。
网关 配置类型用于配置 HTTP 用户以连接到 Web API 和 Ambari 门户。
核心站点 配置类型用于配置群集的默认存储帐户。 |
computeProfile
| 元素名称 |
必需 |
类型 |
Description |
| clusterVersion |
是 |
String |
指定群集版本。 |
| 角色 |
是 |
复杂类型数组(角色) |
提供关于群集内角色的信息。 |
角色
| 元素名称 |
必需 |
类型 |
Description |
| name |
是 |
String |
指定角色名称。 |
| targetInstanceCount |
是 |
Integer |
指定角色的目标实例数量。 |
| hardwareProfile |
是 |
复杂类型 |
指定有关角色的硬件属性的信息。 |
| osProfile |
是 |
复杂类型 |
指定有关角色的操作系统配置文件的信息。 |
hardwareProfile
| 元素名称 |
必需 |
类型 |
Description |
| vmSize |
是 |
String |
指定虚拟机的大小。 有关有效大小,请参阅 HDInsight 配置选项 (向下滚动到 节点定价层)。 |
osProfile
| 元素名称 |
必需 |
类型 |
Description |
| linuxOperatingSystemProfile |
否 |
复杂类型 |
指定与 Linux OS 相关的设置。 |
| Windows操作系统配置文件 |
否 |
复杂类型 |
指定与 Windows OS 相关的设置。 |
| virtualNetworkProfile |
否 |
复杂类型 |
指定在用户订阅中的虚拟网络中部署群集时与虚拟网络相关的设置。 |
| scriptActions |
否 |
复杂类型的数组 |
列出在群集上执行的脚本操作。 |
linuxOperatingSystemProfile
| 元素名称 |
必需 |
类型 |
Description |
| 用户名 |
是 |
String |
SSH 用户名。 |
| sshProfile |
否 |
复杂类型 |
指定 SSH 密钥。 需要 sshProfile 或密码之一。 |
| 密码 |
否 |
String |
指定 SSH 密码。 需要 sshProfile 或密码之一。 |
sshProfile
| 元素名称 |
必需 |
类型 |
Description |
| publicKeys |
是 |
阵 列 |
包含 certificateData 对象的列表。 该值是 ssh-rsa 公钥。 |
Windows操作系统配置文件
| 元素名称 |
必需 |
类型 |
Description |
| rdpSettings |
否 |
复杂类型 |
指定 Windows 群集的 RDP 设置。 |
rdpSettings
| 元素名称 |
必需 |
类型 |
Description |
| 用户名 |
是 |
String |
指定 RDP 用户名。 |
| 密码 |
是 |
String |
指定 RDP 用户的密码。 |
| expiryDate |
是 |
Date |
RDP 凭据的到期日期。 |
virtualNetworkProfile
| 元素名称 |
必需 |
类型 |
Description |
| ID |
是 |
String |
虚拟网络资源 ID。 |
| 子网 |
是 |
String |
指定子网名称。 |
scriptActions
| 元素名称 |
必需 |
类型 |
Description |
| name |
是 |
String |
脚本操作的友好名称。 |
| URI |
是 |
String |
脚本操作文件的 URL。 |
| parameters |
否 |
String |
执行脚本操作文件时要传递的参数。 |
响应
如果验证已完成且请求已接受,则作返回 200 (确定)。
状态代码: 200 正常
使用 ssh 密钥创建的 Linux 群集的响应正文:
{
"id": "/subscriptions/{ subscription-id }/resourceGroups/myresourcegroup1/providers/Microsoft.HDInsight/ clusters/mycluster ",
"name": "mycluster",
"type": "Microsoft.HDInsight/clusters",
"location": "location-name",
"tags": {
"tag1": "value1",
"tag2": "value2"
},
"properties": {
"clusterVersion": "5.1",
"osType": "Linux",
"tier": "premium",
"clusterDefinition": {
"kind": "hadoop",
"configurations": {
"gateway": {
"restAuthEntraUsers": "[{\"objectID\":\"000000-00000-00000-000000\",\"displayName\":\"User1\",\"upn\":\"user1@contoso.com\"},{\"objectId\":\"000000-00000-00000-00001\",\"displayName\":\"User 2\",\"upn\":\"user2@contoso.com\"}]"
},
"core-site": {
"fs.defaultFS": "wasb://container@storageaccount.blob.core.chinacloudapi.cn",
"fs.azure.account.key.storageaccount.blob.core.chinacloudapi.cn": "storage-account-key"
}
}
},
"securityProfile": {
"directoryType": "ActiveDirectory",
"domain": "mydomain.com",
"organizationalUnitDN": "OU=Hadoop,DC=mydomain,DC=COM",
"ldapsUrls": ["ldaps://mydomain.com:636"],
"domainUsername": "clusteradmin@mydomain.com",
"domainUserPassword": "password",
"clusterUsersGroupDNs": ["ADGroup1", "ADGroup2"]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "username",
"sshProfile": {
"publicKeys": [
{
"certificateData": "ssh-rsa key"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/mysubscriptionid/resourceGroups/myrresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
"subnet": "/subscriptions/mysubscriptionid /resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 1,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "username",
"sshProfile": {
"publicKeys": [
{
"certificateData": " ssh-rsa key"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/mysubscriptionid/resourceGroups/myrresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
"subnet": "/subscriptions/mysubscriptionid /resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "username",
"sshProfile": {
"publicKeys": [
{
"certificateData": "ssh-rsa key"
}
]
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/mysubscriptionid/resourceGroups/myrresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
"subnet": "/subscriptions/mysubscriptionid /resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
}
}
}
]
}
}
}
| 元素名称 |
类型 |
Description |
| 预配状态 |
String |
指示当前预配状态。 |
| clusterState |
String |
指示预配过程中更详细的 HDInsight 群集状态。 |
| 创建日期 |
Date |
收到群集创建请求的日期/时间。 |
| 配额信息 (quotaInfo) |
复杂类型 |
指定群集使用的核心。 |
| 错误 |
错误消息数组 |
如果 provisioningState = “failed”,则包含错误消息。 |
| 连接终结点 |
复杂类型 |
指定群集的公共终结点。 |
连接终结点
| 元素名称 |
类型 |
Description |
| name |
String |
连接终结点的友好名称。 |
| 协议 |
String |
指定要使用的协议(例如:HTTPS、SSH)。 |
| 位置 |
String |
指定要连接的 URL。 |
| 移植 |
int (整数) |
指定要连接的端口。 |
创建已加入域的高级 HDInsight 群集(仅限 Linux)
创建一个包含 Apache Ranger 的高级域连接群集。 用户需要在请求正文中提供 SecurityProfile 来创建安全群集。
请求
有关群集使用的标头和参数,请参阅 通用参数和标头 。
| 方法 |
请求 URI |
| PUT |
https://management.chinacloudapi.cn/subscriptions/{subscription ID}/resourceGroups/{resourceGroup Name}/providers/Microsoft.HDInsight/clusters/{cluster name}?api-version={api-version} |
以下示例演示用于创建已启用 Entra 的基于 Linux、高级、已加入域的 Hadoop 群集的请求正文。
{
"id": "/subscriptions/{ subscription-id }/resourceGroups/myresourcegroup1/providers/Microsoft.HDInsight/ clusters/mycluster ", "
name "
: "mycluster",
"type": "Microsoft.HDInsight/clusters",
"location": "location-name",
"tags": {
"tag1": "value1",
"tag2": "value2"
},
"properties": {
"clusterVersion": "5.1",
"osType": "Linux",
"tier": "premium",
"clusterDefinition": {
"kind": "hadoop",
"configurations": {
"gateway": {
"restAuthEntraUsers": "[{\"objectId\":\"000000-00000-00000-000000\",\"displayName\":\"User1\",\"upn\":\"user1@contoso.com\"},{\"objectId\":\"000000-00000-00000-00001\",\"displayName\":\"User 2\",\"upn\":\"user2@contoso.com\"}]"
},
"core-site": {
"fs.defaultFS": "wasb://container@storageaccount.blob.core.chinacloudapi.cn",
"fs.azure.account.key.storageaccount.blob.core.chinacloudapi.cn": "storage-account-key"
}
}
},
"securityProfile": {
"directoryType": "ActiveDirectory",
"domain": "mydomain.com",
"organizationalUnitDN": "OU=Hadoop,DC=mydomain,DC=COM",
"ldapsUrls": ["ldaps://mydomain.com:636"],
"domainUsername": "clusteradmin@mydomain.com",
"domainUserPassword": "password",
"clusterUsersGroupDNs": ["ADGroup1", "ADGroup2"]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "username",
"sshProfile": {
"publicKeys": [
{
"certificateData": "ssh-rsa key"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/mysubscriptionid/resourceGroups/myrresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
"subnet": "/subscriptions/mysubscriptionid /resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 1,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "username",
"sshProfile": {
"publicKeys": [
{
"certificateData": " ssh-rsa key"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/mysubscriptionid/resourceGroups/myrresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
"subnet": "/subscriptions/mysubscriptionid /resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "username",
"sshProfile": {
"publicKeys": [
{
"certificateData": "ssh-rsa key"
}
]
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/mysubscriptionid/resourceGroups/myrresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork",
"subnet": "/subscriptions/mysubscriptionid /resourceGroups/myresourcegroup/providers/Microsoft.Network/virtualNetworks/myvirtualnetwork/subnets/mysubnet"
}
}
}
]
}
}
}
| 元素名称 |
必需 |
类型 |
Description |
| ID |
是 |
String |
指定群集的资源标识符。 |
| name |
是 |
String |
指定群集的名称。 |
| 类型 |
是 |
String |
指定群集的类型。 |
| 位置 |
是 |
String |
指定应在其中创建群集的受支持 Azure 位置。 有关详细信息,请参阅 列出所有可用的地理位置。 |
| tags |
否 |
String |
指定要分配给群集的标记。 有关使用标记的详细信息,请参阅 使用标记来组织 Azure 资源。 |
| 属性 |
是 |
复杂类型 |
指定群集的属性。 |
属性
| 元素名称 |
必需 |
类型 |
Description |
| clusterVersion |
是 |
String |
指定群集版本。 |
| osType |
是 |
String |
指定群集的操作系统。 有效值为 Linux,因为只有 Linux 群集类型才能加入 Azure AD 域。 |
| 分层 |
否 |
String |
默认值为标准值。 有效值为标准值和高级值。 如果未指定任何值,则假定该值为标准值。 指定群集的层级。 仅在高级层中支持已加入域的群集。 |
| clusterDefinition |
是 |
复杂类型 |
指定有关群集类型和配置的信息。 |
| computeProfile |
是 |
复杂类型 |
指定有关群集拓扑和关联角色属性的信息。 |
| securityProfile |
否 |
复杂类型 |
如果要创建已加入域的安全群集,则此元素指定 Active Directory 相关设置。 |
clusterDefinition
| 元素名称 |
必需 |
类型 |
Description |
| kind |
是 |
String |
指定群集类型。 有效值为 hadoop、hbase、storm 和 spark。 |
| configurations |
是 |
字典 |
此元素是配置类型的字典及其关联的值字典。
网关 配置类型用于配置 HTTP 用户以连接到 Web API 和 Ambari 门户。
核心站点 配置类型用于配置群集的默认存储帐户。 |
computeProfile
| 元素名称 |
必需 |
类型 |
Description |
| clusterVersion |
是 |
String |
指定群集版本。 |
| 角色 |
是 |
复杂类型数组(角色) |
提供关于群集内角色的信息。 |
securityProfile
| 元素名称 |
必需 |
类型 |
Description |
| 目录类型 |
是 |
String |
使用的 LDAP 目录的类型。 目前,“ActiveDirectory”是唯一受支持的值。 |
| 域 |
是 |
String |
群集的 Active Directory 域。 |
| 组织单位DN |
是 |
String |
Active Directory 中创建用户和计算机帐户的组织单位的可分辨名称。 |
| ldapsUrls |
是 |
字符串数组 |
Active Directory 中一个或多个 LDAPS 服务器的 URL。 |
| domainUserName |
是 |
String |
具有创建群集的足够权限的域用户帐户。 它应采用user@domain格式。 |
| domainUserPassword 域名用户密码 |
是 |
String |
域用户帐户的密码。 |
| clusterUsersGroupDNS |
否 |
字符串数组 |
将会在 Ambari 和 Apache Ranger 中可用的 Active Directory 组的专有名称。 |
角色
| 元素名称 |
必需 |
类型 |
Description |
| name |
是 |
String |
指定角色名称。 |
| targetInstanceCount |
是 |
Integer |
指定角色的目标实例数量。 |
| hardwareProfile |
是 |
复杂类型 |
指定有关角色的硬件属性的信息。 |
| osProfile |
是 |
复杂类型 |
指定有关角色的操作系统配置文件的信息。 |
hardwareProfile
| 元素名称 |
必需 |
类型 |
Description |
| vmSize |
是 |
String |
指定 VM 的大小。 有关有效大小,请参阅 HDInsight 配置选项 (向下滚动到 节点定价层)。 |
osProfile
| 元素名称 |
必需 |
类型 |
Description |
| linuxOperatingSystemProfile |
否 |
复杂类型 |
指定与 Linux OS 相关的设置。 |
| virtualNetworkProfile |
否 |
复杂类型 |
指定在用户订阅中的虚拟网络中部署群集时与虚拟网络相关的设置。 |
| scriptActions |
否 |
复杂类型的数组 |
列出在群集上执行的脚本操作。 |
linuxOperatingSystemProfile
| 元素名称 |
必需 |
类型 |
Description |
| 用户名 |
是 |
String |
SSH 用户名。 |
| sshProfile |
否 |
复杂类型 |
指定 SSH 密钥。 需要 sshProfile 或密码之一。 |
| 密码 |
否 |
String |
指定 SSH 密码。 需要 sshProfile 或密码之一。 |
sshProfile
| 元素名称 |
必需 |
类型 |
Description |
| publicKeys |
是 |
阵 列 |
包含 certificateData 对象的列表。 该值是 ssh-rsa 公钥。 |
virtualNetworkProfile
| 元素名称 |
必需 |
类型 |
Description |
| ID |
是 |
String |
虚拟网络资源 ID。 |
| 子网 |
是 |
String |
指定子网名称。 |
scriptActions
| 元素名称 |
必需 |
类型 |
Description |
| name |
是 |
String |
脚本操作的友好名称。 |
| URI |
是 |
String |
脚本操作文件的 URL。 |
| parameters |
否 |
String |
执行脚本操作文件时要传递的参数。 |
响应
如果验证已完成且请求已接受,则作返回 200 (确定)。
状态代码:200 正常
使用 SSH 密钥为 Linux 群集创建的响应主体:
{
"id":"/subscriptions/{subscription-id}/resourceGroups/myresourcegroup1/providers/Microsoft.HDInsight/clusters/mycluster",
"name":"mycluster",
"type":"Microsoft.HDInsight/clusters",
"location": "location-name",
"tags": { "tag1": "value1", "tag2": "value2" },
"properties": {
"clusterVersion": "5.1",
"osType": "Linux",
"provisioningState": "InProgress",
"clusterState": "Accepted",
"createdDate": "2015-09-23",
"quotaInfo": {
"coresUsed": 20
}
"clusterDefinition": {
"kind": "hadoop"
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
}
},
{
"name": "workernode",
"targetInstanceCount": 1,
"hardwareProfile": {
"vmSize": "Large"
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
}
}
]
}
}
}
| 元素名称 |
类型 |
Description |
| 预配状态 |
String |
指示当前预配状态。 |
| clusterState |
String |
指示预配过程中更详细的 HDInsight 群集状态。 |
| 创建日期 |
Date |
收到群集创建请求的日期/时间。 |
| 配额信息 (quotaInfo) |
复杂类型 |
指定群集使用的核心。 |
| 错误 |
错误消息数组 |
如果 provisioningState = “failed”,则包含错误消息。 |
| 连接终结点 |
复杂类型 |
指定群集的公共终结点。 |
连接终结点
| 元素名称 |
类型 |
Description |
| name |
String |
连接终结点的友好名称。 |
| 协议 |
String |
指定要使用的协议(例如:HTTPS、SSH)。 |
| 位置 |
String |
指定要连接的 URL。 |
| 移植 |
int (整数) |
指定要连接的端口。 |
使用 Azure Data Lake Store 作为默认文件系统创建群集
使用 Azure Data Lake Store 作为默认文件系统在指定的订阅中创建群集。 在请求正文中提供 ClusterIdentity 对象,并使用相应的 Data Lake Store URL 配置 默认文件系统 属性。
可将 Azure Data Lake 配置为从 5.1 开始(含 5.1)的群集版本的默认文件系统。
请求
有关群集使用的标头和参数,请参阅 通用参数 和标头。
此示例演示使用 Azure Data Lake Store 作为群集的默认文件系统创建基于 Linux 的 Hadoop 群集的请求正文。
| 方法 |
请求 URI |
| PUT |
https://management.chinacloudapi.cn/subscriptions/{subscription Id}/resourceGroups/{resourceGroup Name}/providers/Microsoft.HDInsight/clusters/{cluster name}?api-version={api-version} |