使用指定的参数创建新的 HDInsight 群集。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}?api-version=2021-06-01
URI 参数
| 名称 |
在 |
必需 |
类型 |
说明 |
|
clusterName
|
path |
True
|
string
|
群集的名称。
|
|
resourceGroupName
|
path |
True
|
string
|
资源组的名称。
|
|
subscriptionId
|
path |
True
|
string
|
唯一标识Microsoft Azure 订阅的订阅凭据。 订阅 ID 构成了每个服务调用的 URI 的一部分。
|
|
api-version
|
query |
True
|
string
|
HDInsight 客户端 API 版本。
|
请求正文
响应
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 |
说明 |
|
user_impersonation
|
模拟用户帐户
|
示例
Create cluster with availability zones
示例请求
PUT https://management.azure.com/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"zones": [
"1"
],
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"clusterDefinition": {
"kind": "hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
},
"ambari-conf": {
"database-server": "{sql server name}.database.windows.net",
"database-name": "{ambari database name}",
"database-user-name": "**********",
"database-user-password": "**********"
},
"hive-site": {
"javax.jdo.option.ConnectionURL": "jdbc:sqlserver://{sql server name}.database.windows.net;database={hive metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"javax.jdo.option.ConnectionUserName": "**********",
"javax.jdo.option.ConnectionPassword": "**********!",
"javax.jdo.option.ConnectionDriverName": "com.microsoft.sqlserver.jdbc.SQLServerDriver"
},
"hive-env": {
"hive_database": "Existing MSSQL Server database with SQL authentication",
"hive_database_name": "{hive metastore name}",
"hive_database_type": "mssql",
"hive_existing_mssql_server_database": "{hive metastore name}",
"hive_existing_mssql_server_host": "{sql server name}.database.windows.net",
"hive_hostname": "{sql server name}.database.windows.net"
},
"oozie-site": {
"oozie.service.JPAService.jdbc.url": "jdbc:sqlserver://{sql server name}.database.windows.net;database={oozie metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"oozie.service.JPAService.jdbc.username": "**********",
"oozie.service.JPAService.jdbc.password": "**********",
"oozie.service.JPAService.jdbc.driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"oozie.db.schema.name": "oozie"
},
"oozie-env": {
"oozie_database": "Existing MSSQL Server database with SQL authentication",
"oozie_database_name": "{oozie metastore name}",
"oozie_database_type": "mssql",
"oozie_existing_mssql_server_database": "{oozie metastore name}",
"oozie_existing_mssql_server_host": "{sql server name}.database.windows.net",
"oozie_hostname": "{sql server name}.database.windows.net"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage",
"isDefault": true,
"container": "containername",
"key": "storage account key"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.SshProfile;
import com.azure.resourcemanager.hdinsight.models.SshPublicKey;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.VirtualNetworkProfile;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAvailabilityZones.json
*/
/**
* Sample code: Create cluster with availability zones.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createClusterWithAvailabilityZones(com.azure.resourcemanager.hdinsight.HDInsightManager manager)
throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withZones(Arrays.asList("1"))
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withClusterDefinition(
new ClusterDefinition()
.withKind("hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"ambari-conf\":{\"database-name\":\"{ambari database"
+ " name}\",\"database-server\":\"{sql server"
+ " name}.database.windows.net\",\"database-user-name\":\"**********\",\"database-user-password\":\"**********\"},\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"},\"hive-env\":{\"hive_database\":\"Existing"
+ " MSSQL Server database with SQL"
+ " authentication\",\"hive_database_name\":\"{hive metastore"
+ " name}\",\"hive_database_type\":\"mssql\",\"hive_existing_mssql_server_database\":\"{hive"
+ " metastore name}\",\"hive_existing_mssql_server_host\":\"{sql server"
+ " name}.database.windows.net\",\"hive_hostname\":\"{sql server"
+ " name}.database.windows.net\"},\"hive-site\":{\"javax.jdo.option.ConnectionDriverName\":\"com.microsoft.sqlserver.jdbc.SQLServerDriver\",\"javax.jdo.option.ConnectionPassword\":\"**********!\",\"javax.jdo.option.ConnectionURL\":\"jdbc:sqlserver://{sql"
+ " server name}.database.windows.net;database={hive metastore"
+ " name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0\",\"javax.jdo.option.ConnectionUserName\":\"**********\"},\"oozie-env\":{\"oozie_database\":\"Existing"
+ " MSSQL Server database with SQL"
+ " authentication\",\"oozie_database_name\":\"{oozie metastore"
+ " name}\",\"oozie_database_type\":\"mssql\",\"oozie_existing_mssql_server_database\":\"{oozie"
+ " metastore name}\",\"oozie_existing_mssql_server_host\":\"{sql server"
+ " name}.database.windows.net\",\"oozie_hostname\":\"{sql server"
+ " name}.database.windows.net\"},\"oozie-site\":{\"oozie.db.schema.name\":\"oozie\",\"oozie.service.JPAService.jdbc.driver\":\"com.microsoft.sqlserver.jdbc.SQLServerDriver\",\"oozie.service.JPAService.jdbc.password\":\"**********\",\"oozie.service.JPAService.jdbc.url\":\"jdbc:sqlserver://{sql"
+ " server name}.database.windows.net;database={oozie metastore"
+ " name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0\",\"oozie.service.JPAService.jdbc.username\":\"**********\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("standard_d3"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet")),
new Role()
.withName("workernode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("standard_d3"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet")))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_availability_zones.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subId",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"ambari-conf": {
"database-name": "{ambari database name}",
"database-server": "{sql server name}.database.windows.net",
"database-user-name": "**********",
"database-user-password": "**********",
},
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
"hive-env": {
"hive_database": "Existing MSSQL Server database with SQL authentication",
"hive_database_name": "{hive metastore name}",
"hive_database_type": "mssql",
"hive_existing_mssql_server_database": "{hive metastore name}",
"hive_existing_mssql_server_host": "{sql server name}.database.windows.net",
"hive_hostname": "{sql server name}.database.windows.net",
},
"hive-site": {
"javax.jdo.option.ConnectionDriverName": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"javax.jdo.option.ConnectionPassword": "**********!",
"javax.jdo.option.ConnectionURL": "jdbc:sqlserver://{sql server name}.database.windows.net;database={hive metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"javax.jdo.option.ConnectionUserName": "**********",
},
"oozie-env": {
"oozie_database": "Existing MSSQL Server database with SQL authentication",
"oozie_database_name": "{oozie metastore name}",
"oozie_database_type": "mssql",
"oozie_existing_mssql_server_database": "{oozie metastore name}",
"oozie_existing_mssql_server_host": "{sql server name}.database.windows.net",
"oozie_hostname": "{sql server name}.database.windows.net",
},
"oozie-site": {
"oozie.db.schema.name": "oozie",
"oozie.service.JPAService.jdbc.driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"oozie.service.JPAService.jdbc.password": "**********",
"oozie.service.JPAService.jdbc.url": "jdbc:sqlserver://{sql server name}.database.windows.net;database={oozie metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"oozie.service.JPAService.jdbc.username": "**********",
},
},
"kind": "hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "standard_d3"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
"hardwareProfile": {"vmSize": "standard_d3"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storage account key",
"name": "mystorage",
}
]
},
},
"zones": ["1"],
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAvailabilityZones.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAvailabilityZones.json
func ExampleClustersClient_BeginCreate_createClusterWithAvailabilityZones() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"ambari-conf": map[string]any{
"database-name": "{ambari database name}",
"database-server": "{sql server name}.database.windows.net",
"database-user-name": "**********",
"database-user-password": "**********",
},
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
"hive-env": map[string]any{
"hive_database": "Existing MSSQL Server database with SQL authentication",
"hive_database_name": "{hive metastore name}",
"hive_database_type": "mssql",
"hive_existing_mssql_server_database": "{hive metastore name}",
"hive_existing_mssql_server_host": "{sql server name}.database.windows.net",
"hive_hostname": "{sql server name}.database.windows.net",
},
"hive-site": map[string]any{
"javax.jdo.option.ConnectionDriverName": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"javax.jdo.option.ConnectionPassword": "**********!",
"javax.jdo.option.ConnectionURL": "jdbc:sqlserver://{sql server name}.database.windows.net;database={hive metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"javax.jdo.option.ConnectionUserName": "**********",
},
"oozie-env": map[string]any{
"oozie_database": "Existing MSSQL Server database with SQL authentication",
"oozie_database_name": "{oozie metastore name}",
"oozie_database_type": "mssql",
"oozie_existing_mssql_server_database": "{oozie metastore name}",
"oozie_existing_mssql_server_host": "{sql server name}.database.windows.net",
"oozie_hostname": "{sql server name}.database.windows.net",
},
"oozie-site": map[string]any{
"oozie.db.schema.name": "oozie",
"oozie.service.JPAService.jdbc.driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"oozie.service.JPAService.jdbc.password": "**********",
"oozie.service.JPAService.jdbc.url": "jdbc:sqlserver://{sql server name}.database.windows.net;database={oozie metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"oozie.service.JPAService.jdbc.username": "**********",
},
},
Kind: to.Ptr("hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("standard_d3"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("standard_d3"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storage account key"),
}},
},
},
Zones: []*string{
to.Ptr("1")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2005040905.json"),
// Kind: to.Ptr("hadoop"),
// },
// ClusterID: to.Ptr("8186508b6234470e9d16c9e8e13bd821"),
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("3.6.1000.67"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
// ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
// Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
// },
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
// ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
// Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
// },
// }},
// },
// CreatedDate: to.Ptr("2020-06-09T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](16),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// Zones: []*string{
// to.Ptr("1")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAvailabilityZones.json
*/
async function createClusterWithAvailabilityZones() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subId";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
"ambari-conf": {
"database-name": "{ambari database name}",
"database-server": "{sql server name}.database.windows.net",
"database-user-name": "**********",
"database-user-password": "**********",
},
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
"hive-env": {
hive_database: "Existing MSSQL Server database with SQL authentication",
hive_database_name: "{hive metastore name}",
hive_database_type: "mssql",
hive_existing_mssql_server_database: "{hive metastore name}",
hive_existing_mssql_server_host: "{sql server name}.database.windows.net",
hive_hostname: "{sql server name}.database.windows.net",
},
"hive-site": {
"javax.jdo.option.ConnectionDriverName": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"javax.jdo.option.ConnectionPassword": "**********!",
"javax.jdo.option.ConnectionURL":
"jdbc:sqlserver://{sql server name}.database.windows.net;database={hive metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"javax.jdo.option.ConnectionUserName": "**********",
},
"oozie-env": {
oozie_database: "Existing MSSQL Server database with SQL authentication",
oozie_database_name: "{oozie metastore name}",
oozie_database_type: "mssql",
oozie_existing_mssql_server_database: "{oozie metastore name}",
oozie_existing_mssql_server_host: "{sql server name}.database.windows.net",
oozie_hostname: "{sql server name}.database.windows.net",
},
"oozie-site": {
"oozie.db.schema.name": "oozie",
"oozie.service.JPAService.jdbc.driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"oozie.service.JPAService.jdbc.password": "**********",
"oozie.service.JPAService.jdbc.url":
"jdbc:sqlserver://{sql server name}.database.windows.net;database={oozie metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
"oozie.service.JPAService.jdbc.username": "**********",
},
},
kind: "hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "standard_d3" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
name: "workernode",
hardwareProfile: { vmSize: "standard_d3" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage",
container: "containername",
isDefault: true,
key: "storage account key",
},
],
},
},
zones: ["1"],
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAvailabilityZones.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subId";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Zones =
{
"1"
},
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["ambari-conf"] = new Dictionary<string, object>()
{
["database-name"] = "{ambari database name}",
["database-server"] = "{sql server name}.database.windows.net",
["database-user-name"] = "**********",
["database-user-password"] = "**********"
},
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
},
["hive-env"] = new Dictionary<string, object>()
{
["hive_database"] = "Existing MSSQL Server database with SQL authentication",
["hive_database_name"] = "{hive metastore name}",
["hive_database_type"] = "mssql",
["hive_existing_mssql_server_database"] = "{hive metastore name}",
["hive_existing_mssql_server_host"] = "{sql server name}.database.windows.net",
["hive_hostname"] = "{sql server name}.database.windows.net"
},
["hive-site"] = new Dictionary<string, object>()
{
["javax.jdo.option.ConnectionDriverName"] = "com.microsoft.sqlserver.jdbc.SQLServerDriver",
["javax.jdo.option.ConnectionPassword"] = "**********!",
["javax.jdo.option.ConnectionURL"] = "jdbc:sqlserver://{sql server name}.database.windows.net;database={hive metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
["javax.jdo.option.ConnectionUserName"] = "**********"
},
["oozie-env"] = new Dictionary<string, object>()
{
["oozie_database"] = "Existing MSSQL Server database with SQL authentication",
["oozie_database_name"] = "{oozie metastore name}",
["oozie_database_type"] = "mssql",
["oozie_existing_mssql_server_database"] = "{oozie metastore name}",
["oozie_existing_mssql_server_host"] = "{sql server name}.database.windows.net",
["oozie_hostname"] = "{sql server name}.database.windows.net"
},
["oozie-site"] = new Dictionary<string, object>()
{
["oozie.db.schema.name"] = "oozie",
["oozie.service.JPAService.jdbc.driver"] = "com.microsoft.sqlserver.jdbc.SQLServerDriver",
["oozie.service.JPAService.jdbc.password"] = "**********",
["oozie.service.JPAService.jdbc.url"] = "jdbc:sqlserver://{sql server name}.database.windows.net;database={oozie metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0",
["oozie.service.JPAService.jdbc.username"] = "**********"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "standard_d3",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 2,
HardwareVmSize = "standard_d3",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage",
IsDefault = true,
Container = "containername",
Key = "storage account key",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"tags": null,
"zones": [
"1"
],
"properties": {
"clusterVersion": "3.6.1000.67",
"osType": "Linux",
"clusterId": "8186508b6234470e9d16c9e8e13bd821",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2005040905.json",
"kind": "hadoop"
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2020-06-09T12:25:43.48",
"quotaInfo": {
"coresUsed": 16
},
"tier": "Standard"
}
}
Create cluster with compute isolation properties
示例请求
PUT https://management.azure.com/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"clusterDefinition": {
"kind": "hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage",
"isDefault": true,
"container": "containername",
"key": "storage account key"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
}
},
{
"name": "workernode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
}
}
]
},
"computeIsolationProperties": {
"enableComputeIsolation": true,
"hostSku": null
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeIsolationProperties;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.SshProfile;
import com.azure.resourcemanager.hdinsight.models.SshPublicKey;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithComputeIsolationProperties.json
*/
/**
* Sample code: Create cluster with compute isolation properties.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createClusterWithComputeIsolationProperties(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withClusterDefinition(
new ClusterDefinition()
.withKind("hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("standard_d3"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********")))))),
new Role()
.withName("workernode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("standard_d3"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********")))))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder"))))
.withComputeIsolationProperties(new ComputeIsolationProperties().withEnableComputeIsolation(true)))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_compute_isolation_properties.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subId",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "hadoop",
},
"clusterVersion": "3.6",
"computeIsolationProperties": {"enableComputeIsolation": True, "hostSku": None},
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "standard_d3"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "standard_d3"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
},
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storage account key",
"name": "mystorage",
}
]
},
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithComputeIsolationProperties.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithComputeIsolationProperties.json
func ExampleClustersClient_BeginCreate_createClusterWithComputeIsolationProperties() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeIsolationProperties: &armhdinsight.ComputeIsolationProperties{
EnableComputeIsolation: to.Ptr(true),
},
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("standard_d3"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("standard_d3"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storage account key"),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2005040905.json"),
// Kind: to.Ptr("hadoop"),
// },
// ClusterID: to.Ptr("8186508b6234470e9d16c9e8e13bd821"),
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("3.6.1000.67"),
// ComputeIsolationProperties: &armhdinsight.ComputeIsolationProperties{
// EnableComputeIsolation: to.Ptr(true),
// },
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
// ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
// Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
// },
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// }},
// },
// CreatedDate: to.Ptr("2020-06-09T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](16),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithComputeIsolationProperties.json
*/
async function createClusterWithComputeIsolationProperties() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subId";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "hadoop",
},
clusterVersion: "3.6",
computeIsolationProperties: {
enableComputeIsolation: true,
hostSku: undefined,
},
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "standard_d3" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "standard_d3" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage",
container: "containername",
isDefault: true,
key: "storage account key",
},
],
},
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithComputeIsolationProperties.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subId";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "standard_d3",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 2,
HardwareVmSize = "standard_d3",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage",
IsDefault = true,
Container = "containername",
Key = "storage account key",
}
},
ComputeIsolationProperties = new HDInsightComputeIsolationProperties()
{
EnableComputeIsolation = true,
HostSku = null,
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"tags": null,
"properties": {
"clusterVersion": "3.6.1000.67",
"osType": "Linux",
"clusterId": "8186508b6234470e9d16c9e8e13bd821",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2005040905.json",
"kind": "hadoop"
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"computeIsolationProperties": {
"enableComputeIsolation": true,
"hostSku": null
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2020-06-09T12:25:43.48",
"quotaInfo": {
"coresUsed": 16
},
"tier": "Standard"
}
}
Create cluster with encryption at host
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_DS14_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Standard_DS14_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Standard_DS14_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "default8525",
"key": "storagekey"
}
]
},
"diskEncryptionProperties": {
"encryptionAtHost": true
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.DiskEncryptionProperties;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionAtHost.json
*/
/**
* Sample code: Create cluster with encryption at host.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createClusterWithEncryptionAtHost(com.azure.resourcemanager.hdinsight.HDInsightManager manager)
throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_DS14_v2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_DS14_v2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("zookeepernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_DS14_v2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("default8525")
.withKey("fakeTokenPlaceholder"))))
.withDiskEncryptionProperties(new DiskEncryptionProperties().withEncryptionAtHost(true)))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_encryption_at_host.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Standard_DS14_v2"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Standard_DS14_v2"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
{
"hardwareProfile": {"vmSize": "Standard_DS14_v2"},
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
]
},
"diskEncryptionProperties": {"encryptionAtHost": True},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "default8525",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionAtHost.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionAtHost.json
func ExampleClustersClient_BeginCreate_createClusterWithEncryptionAtHost() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_DS14_v2"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_DS14_v2"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_DS14_v2"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
}},
},
DiskEncryptionProperties: &armhdinsight.DiskEncryptionProperties{
EncryptionAtHost: to.Ptr(true),
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("default8525"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("3b76ce3d-892c-4036-9d8b-8ade18ba7a4b"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2001080246.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("2.7"),
// },
// Kind: to.Ptr("Hadoop"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("3.6.1000.67"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_ds14_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_ds14_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_ds14_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2020-01-10T08:36:39.153"),
// DiskEncryptionProperties: &armhdinsight.DiskEncryptionProperties{
// EncryptionAtHost: to.Ptr(true),
// },
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](20),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionAtHost.json
*/
async function createClusterWithEncryptionAtHost() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Standard_DS14_v2" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Standard_DS14_v2" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Standard_DS14_v2" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
],
},
diskEncryptionProperties: { encryptionAtHost: true },
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "default8525",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionAtHost.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "Standard_DS14_v2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 3,
HardwareVmSize = "Standard_DS14_v2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
TargetInstanceCount = 3,
HardwareVmSize = "Standard_DS14_v2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "default8525",
Key = "storagekey",
}
},
DiskEncryptionProperties = new HDInsightDiskEncryptionProperties()
{
IsEncryptionAtHostEnabled = true,
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "3b76ce3d-892c-4036-9d8b-8ade18ba7a4b",
"tags": null,
"properties": {
"clusterVersion": "3.6.1000.67",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2001080246.json",
"kind": "Hadoop",
"componentVersion": {
"Hadoop": "2.7"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_ds14_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_ds14_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_ds14_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2020-01-10T08:36:39.153",
"quotaInfo": {
"coresUsed": 20
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard",
"diskEncryptionProperties": {
"vaultUri": null,
"keyName": null,
"keyVersion": null,
"encryptionAlgorithm": null,
"msiResourceId": null,
"encryptionAtHost": true
}
}
}
Create cluster with encryption in transit
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "default8525",
"key": "storagekey"
}
]
},
"encryptionInTransitProperties": {
"isEncryptionInTransitEnabled": true
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.EncryptionInTransitProperties;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionInTransit.json
*/
/**
* Sample code: Create cluster with encryption in transit.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createClusterWithEncryptionInTransit(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Large"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Large"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("zookeepernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("default8525")
.withKey("fakeTokenPlaceholder"))))
.withEncryptionInTransitProperties(
new EncryptionInTransitProperties().withIsEncryptionInTransitEnabled(true)))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_encryption_in_transit.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Large"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Large"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
{
"hardwareProfile": {"vmSize": "Small"},
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
]
},
"encryptionInTransitProperties": {"isEncryptionInTransitEnabled": True},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "default8525",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionInTransit.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionInTransit.json
func ExampleClustersClient_BeginCreate_createClusterWithEncryptionInTransit() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Large"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Large"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
}},
},
EncryptionInTransitProperties: &armhdinsight.EncryptionInTransitProperties{
IsEncryptionInTransitEnabled: to.Ptr(true),
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("default8525"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("3b76ce3d-892c-4036-9d8b-8ade18ba7a4b"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2001080246.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("2.7"),
// },
// Kind: to.Ptr("Hadoop"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("3.6.1000.67"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2020-01-10T08:36:39.153"),
// EncryptionInTransitProperties: &armhdinsight.EncryptionInTransitProperties{
// IsEncryptionInTransitEnabled: to.Ptr(true),
// },
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](20),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionInTransit.json
*/
async function createClusterWithEncryptionInTransit() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Large" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Large" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
],
},
encryptionInTransitProperties: { isEncryptionInTransitEnabled: true },
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "default8525",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithEncryptionInTransit.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "Large",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 3,
HardwareVmSize = "Large",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "default8525",
Key = "storagekey",
}
},
IsEncryptionInTransitEnabled = true,
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "3b76ce3d-892c-4036-9d8b-8ade18ba7a4b",
"tags": null,
"properties": {
"clusterVersion": "3.6.1000.67",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2001080246.json",
"kind": "Hadoop",
"componentVersion": {
"Hadoop": "2.7"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_a4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2020-01-10T08:36:39.153",
"quotaInfo": {
"coresUsed": 20
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard",
"encryptionInTransitProperties": {
"isEncryptionInTransitEnabled": true
}
}
}
Create cluster with network properties
示例请求
PUT https://management.azure.com/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"clusterDefinition": {
"kind": "hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage",
"isDefault": true,
"container": "containername",
"key": "storage account key"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
}
]
},
"networkProperties": {
"resourceProviderConnection": "Outbound",
"privateLink": "Enabled"
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.NetworkProperties;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.PrivateLink;
import com.azure.resourcemanager.hdinsight.models.ResourceProviderConnection;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.SshProfile;
import com.azure.resourcemanager.hdinsight.models.SshPublicKey;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.VirtualNetworkProfile;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithCustomNetworkProperties.json
*/
/**
* Sample code: Create cluster with network properties.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createClusterWithNetworkProperties(com.azure.resourcemanager.hdinsight.HDInsightManager manager)
throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withClusterDefinition(
new ClusterDefinition()
.withKind("hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("standard_d3"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet")),
new Role()
.withName("workernode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("standard_d3"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet")))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder"))))
.withNetworkProperties(
new NetworkProperties()
.withResourceProviderConnection(ResourceProviderConnection.OUTBOUND)
.withPrivateLink(PrivateLink.ENABLED)))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_custom_network_properties.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subId",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "standard_d3"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
"hardwareProfile": {"vmSize": "standard_d3"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
]
},
"networkProperties": {"privateLink": "Enabled", "resourceProviderConnection": "Outbound"},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storage account key",
"name": "mystorage",
}
]
},
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithCustomNetworkProperties.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithCustomNetworkProperties.json
func ExampleClustersClient_BeginCreate_createClusterWithNetworkProperties() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("standard_d3"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("standard_d3"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
}},
},
NetworkProperties: &armhdinsight.NetworkProperties{
PrivateLink: to.Ptr(armhdinsight.PrivateLinkEnabled),
ResourceProviderConnection: to.Ptr(armhdinsight.ResourceProviderConnectionOutbound),
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storage account key"),
}},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2005040905.json"),
// Kind: to.Ptr("hadoop"),
// },
// ClusterID: to.Ptr("8186508b6234470e9d16c9e8e13bd821"),
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("3.6.1000.67"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
// ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
// Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
// },
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
// ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
// Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
// },
// }},
// },
// CreatedDate: to.Ptr("2020-06-09T12:25:43.48"),
// NetworkProperties: &armhdinsight.NetworkProperties{
// PrivateLink: to.Ptr(armhdinsight.PrivateLinkEnabled),
// ResourceProviderConnection: to.Ptr(armhdinsight.ResourceProviderConnectionOutbound),
// },
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](16),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithCustomNetworkProperties.json
*/
async function createClusterWithNetworkProperties() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subId";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "standard_d3" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
name: "workernode",
hardwareProfile: { vmSize: "standard_d3" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
],
},
networkProperties: {
privateLink: "Enabled",
resourceProviderConnection: "Outbound",
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage",
container: "containername",
isDefault: true,
key: "storage account key",
},
],
},
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithCustomNetworkProperties.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subId";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "standard_d3",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 2,
HardwareVmSize = "standard_d3",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage",
IsDefault = true,
Container = "containername",
Key = "storage account key",
}
},
NetworkProperties = new HDInsightClusterNetworkProperties()
{
ResourceProviderConnection = HDInsightResourceProviderConnection.Outbound,
PrivateLink = HDInsightPrivateLinkState.Enabled,
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"tags": null,
"properties": {
"clusterVersion": "3.6.1000.67",
"osType": "Linux",
"clusterId": "8186508b6234470e9d16c9e8e13bd821",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2005040905.json",
"kind": "hadoop"
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
},
{
"name": "workernode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
}
}
]
},
"networkProperties": {
"resourceProviderConnection": "Outbound",
"privateLink": "Enabled"
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2020-06-09T12:25:43.48",
"quotaInfo": {
"coresUsed": 16
},
"tier": "Standard"
}
}
Create cluster with TLS 1.2
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "default8525",
"key": "storagekey"
}
]
},
"minSupportedTlsVersion": "1.2"
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithTLS12.json
*/
/**
* Sample code: Create cluster with TLS 1.2.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createClusterWithTLS12(com.azure.resourcemanager.hdinsight.HDInsightManager manager)
throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Large"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Large"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("zookeepernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("default8525")
.withKey("fakeTokenPlaceholder"))))
.withMinSupportedTlsVersion("1.2"))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_tls12.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Large"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Large"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
{
"hardwareProfile": {"vmSize": "Small"},
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
]
},
"minSupportedTlsVersion": "1.2",
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "default8525",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithTLS12.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithTLS12.json
func ExampleClustersClient_BeginCreate_createClusterWithTls12() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Large"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Large"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
}},
},
MinSupportedTLSVersion: to.Ptr("1.2"),
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("default8525"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("3b76ce3d-892c-4036-9d8b-8ade18ba7a4b"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2001080246.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("2.7"),
// },
// Kind: to.Ptr("Hadoop"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("3.6.1000.67"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2020-01-10T08:36:39.153"),
// MinSupportedTLSVersion: to.Ptr("1.2"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](20),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithTLS12.json
*/
async function createClusterWithTls12() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Large" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Large" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
],
},
minSupportedTlsVersion: "1.2",
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "default8525",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithTLS12.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "Large",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 3,
HardwareVmSize = "Large",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "default8525",
Key = "storagekey",
}
},
MinSupportedTlsVersion = "1.2",
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "3b76ce3d-892c-4036-9d8b-8ade18ba7a4b",
"tags": null,
"properties": {
"clusterVersion": "3.6.1000.67",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-3.6.1000.67.2001080246.json",
"kind": "Hadoop",
"componentVersion": {
"Hadoop": "2.7"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_a4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2020-01-10T08:36:39.153",
"quotaInfo": {
"coresUsed": 20
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard",
"minSupportedTlsVersion": "1.2"
}
}
Create Hadoop cluster with Azure Data Lake Storage Gen 2
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"tags": {
"key1": "val1"
},
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.dfs.core.windows.net",
"isDefault": true,
"fileSystem": "default",
"key": "storagekey"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"minInstanceCount": 1,
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"minInstanceCount": 1,
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "zookeepernode",
"minInstanceCount": 1,
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopAdlsGen2.json
*/
/**
* Sample code: Create Hadoop cluster with Azure Data Lake Storage Gen 2.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createHadoopClusterWithAzureDataLakeStorageGen2(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withTags(mapOf("key1", "val1"))
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":\"true\",\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withMinInstanceCount(1)
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(4)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("zookeepernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.dfs.core.windows.net")
.withIsDefault(true)
.withFileSystem("default")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_linux_hadoop_adls_gen2.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 4,
},
{
"hardwareProfile": {"vmSize": "Small"},
"minInstanceCount": 1,
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"fileSystem": "default",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.dfs.core.windows.net",
}
]
},
"tier": "Standard",
},
"tags": {"key1": "val1"},
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopAdlsGen2.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopAdlsGen2.json
func ExampleClustersClient_BeginCreate_createHadoopClusterWithAzureDataLakeStorageGen2() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": "true",
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](4),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.dfs.core.windows.net"),
FileSystem: to.Ptr("default"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
Tags: map[string]*string{
"key1": to.Ptr("val1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("East US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("3.1"),
// },
// Kind: to.Ptr("HADOOP"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d12_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-18T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](40),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopAdlsGen2.json
*/
async function createHadoopClusterWithAzureDataLakeStorageGen2() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 4,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.dfs.core.windows.net",
fileSystem: "default",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
tags: { key1: "val1" },
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopAdlsGen2.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Tags =
{
["key1"] = "val1",
},
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
MinInstanceCount = 1,
TargetInstanceCount = 2,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
MinInstanceCount = 1,
TargetInstanceCount = 4,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
MinInstanceCount = 1,
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.dfs.core.windows.net",
IsDefault = true,
FileSystem = "default",
Key = "storagekey",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "East US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json",
"kind": "HADOOP",
"componentVersion": {
"Hadoop": "3.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d12_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-18T12:25:43.48",
"quotaInfo": {
"coresUsed": 40
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard"
}
}
Create Hadoop on Linux cluster with SSH password
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"tags": {
"key1": "val1"
},
"properties": {
"clusterVersion": "3.5",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "containername",
"key": "storagekey"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"minInstanceCount": 1,
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"minInstanceCount": 1,
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "zookeepernode",
"minInstanceCount": 1,
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPassword.json
*/
/**
* Sample code: Create Hadoop on Linux cluster with SSH password.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createHadoopOnLinuxClusterWithSSHPassword(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withTags(mapOf("key1", "val1"))
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.5")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":\"true\",\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withMinInstanceCount(1)
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(4)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("zookeepernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_linux_hadoop_ssh_password.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.5",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 4,
},
{
"hardwareProfile": {"vmSize": "Small"},
"minInstanceCount": 1,
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
},
"tags": {"key1": "val1"},
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPassword.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPassword.json
func ExampleClustersClient_BeginCreate_createHadoopOnLinuxClusterWithSshPassword() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": "true",
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.5"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](4),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
Tags: map[string]*string{
"key1": to.Ptr("val1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("East US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("3.1"),
// },
// Kind: to.Ptr("HADOOP"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d12_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-18T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](40),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPassword.json
*/
async function createHadoopOnLinuxClusterWithSshPassword() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.5",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 4,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "containername",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
tags: { key1: "val1" },
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPassword.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Tags =
{
["key1"] = "val1",
},
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.5",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
MinInstanceCount = 1,
TargetInstanceCount = 2,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
MinInstanceCount = 1,
TargetInstanceCount = 4,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
MinInstanceCount = 1,
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "containername",
Key = "storagekey",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "East US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json",
"kind": "HADOOP",
"componentVersion": {
"Hadoop": "3.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d12_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-18T12:25:43.48",
"quotaInfo": {
"coresUsed": 40
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard"
}
}
Create Hadoop on Linux cluster with SSH public key
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"tags": {
"key1": "val1"
},
"properties": {
"clusterVersion": "3.5",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "containername",
"key": "storagekey"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"minInstanceCount": 1,
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
}
},
{
"name": "workernode",
"minInstanceCount": 1,
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "zookeepernode",
"minInstanceCount": 1,
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.SshProfile;
import com.azure.resourcemanager.hdinsight.models.SshPublicKey;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPublicKey.json
*/
/**
* Sample code: Create Hadoop on Linux cluster with SSH public key.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createHadoopOnLinuxClusterWithSSHPublicKey(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withTags(mapOf("key1", "val1"))
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.5")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withMinInstanceCount(1)
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********")))))),
new Role()
.withName("workernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(4)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("zookeepernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_linux_hadoop_ssh_public_key.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.5",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 4,
},
{
"hardwareProfile": {"vmSize": "Small"},
"minInstanceCount": 1,
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
},
"tags": {"key1": "val1"},
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPublicKey.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPublicKey.json
func ExampleClustersClient_BeginCreate_createHadoopOnLinuxClusterWithSshPublicKey() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.5"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](4),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
Tags: map[string]*string{
"key1": to.Ptr("val1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("East US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("3.1"),
// },
// Kind: to.Ptr("HADOOP"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d12_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-18T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](40),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPublicKey.json
*/
async function createHadoopOnLinuxClusterWithSshPublicKey() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.5",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 4,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "containername",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
tags: { key1: "val1" },
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSshPublicKey.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Tags =
{
["key1"] = "val1",
},
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.5",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
MinInstanceCount = 1,
TargetInstanceCount = 2,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
},new HDInsightClusterRole()
{
Name = "workernode",
MinInstanceCount = 1,
TargetInstanceCount = 4,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
MinInstanceCount = 1,
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "containername",
Key = "storagekey",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "East US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json",
"kind": "HADOOP",
"componentVersion": {
"Hadoop": "3.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d12_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-18T12:25:43.48",
"quotaInfo": {
"coresUsed": 40
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard"
}
}
Create HDInsight cluster with Autoscale configuration
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "3.6",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "hadoop",
"componentVersion": {
"Hadoop": "2.7"
},
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "hdinsight-autoscale-tes-2019-06-18t05-49-16-591z",
"key": "storagekey"
}
]
},
"computeProfile": {
"roles": [
{
"autoscale": {
"capacity": null,
"recurrence": {
"timeZone": "China Standard Time",
"schedule": [
{
"days": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday"
],
"timeAndCapacity": {
"time": "09:00",
"minInstanceCount": 3,
"maxInstanceCount": 3
}
},
{
"days": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday"
],
"timeAndCapacity": {
"time": "18:00",
"minInstanceCount": 6,
"maxInstanceCount": 6
}
},
{
"days": [
"Saturday",
"Sunday"
],
"timeAndCapacity": {
"time": "09:00",
"minInstanceCount": 2,
"maxInstanceCount": 2
}
},
{
"days": [
"Saturday",
"Sunday"
],
"timeAndCapacity": {
"time": "18:00",
"minInstanceCount": 4,
"maxInstanceCount": 4
}
}
]
}
},
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "Standard_D4_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
},
"virtualNetworkProfile": null,
"scriptActions": [],
"dataDisksGroups": null
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.Autoscale;
import com.azure.resourcemanager.hdinsight.models.AutoscaleRecurrence;
import com.azure.resourcemanager.hdinsight.models.AutoscaleSchedule;
import com.azure.resourcemanager.hdinsight.models.AutoscaleTimeAndCapacity;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.DaysOfWeek;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAutoscaleConfig.json
*/
/**
* Sample code: Create HDInsight cluster with Autoscale configuration.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createHDInsightClusterWithAutoscaleConfiguration(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.6")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("hadoop")
.withComponentVersion(mapOf("Hadoop", "2.7"))
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("workernode")
.withTargetInstanceCount(4)
.withAutoscaleConfiguration(
new Autoscale()
.withRecurrence(
new AutoscaleRecurrence()
.withTimeZone("China Standard Time")
.withSchedule(
Arrays
.asList(
new AutoscaleSchedule()
.withDays(
Arrays
.asList(
DaysOfWeek.MONDAY,
DaysOfWeek.TUESDAY,
DaysOfWeek.WEDNESDAY,
DaysOfWeek.THURSDAY,
DaysOfWeek.FRIDAY))
.withTimeAndCapacity(
new AutoscaleTimeAndCapacity()
.withTime("09:00")
.withMinInstanceCount(3)
.withMaxInstanceCount(3)),
new AutoscaleSchedule()
.withDays(
Arrays
.asList(
DaysOfWeek.MONDAY,
DaysOfWeek.TUESDAY,
DaysOfWeek.WEDNESDAY,
DaysOfWeek.THURSDAY,
DaysOfWeek.FRIDAY))
.withTimeAndCapacity(
new AutoscaleTimeAndCapacity()
.withTime("18:00")
.withMinInstanceCount(6)
.withMaxInstanceCount(6)),
new AutoscaleSchedule()
.withDays(
Arrays
.asList(
DaysOfWeek.SATURDAY,
DaysOfWeek.SUNDAY))
.withTimeAndCapacity(
new AutoscaleTimeAndCapacity()
.withTime("09:00")
.withMinInstanceCount(2)
.withMaxInstanceCount(2)),
new AutoscaleSchedule()
.withDays(
Arrays
.asList(
DaysOfWeek.SATURDAY,
DaysOfWeek.SUNDAY))
.withTimeAndCapacity(
new AutoscaleTimeAndCapacity()
.withTime("18:00")
.withMinInstanceCount(4)
.withMaxInstanceCount(4))))))
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D4_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")))
.withScriptActions(Arrays.asList()))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("hdinsight-autoscale-tes-2019-06-18t05-49-16-591z")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_hd_insight_cluster_with_autoscale_config.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"componentVersion": {"Hadoop": "2.7"},
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "hadoop",
},
"clusterVersion": "3.6",
"computeProfile": {
"roles": [
{
"autoscale": {
"capacity": None,
"recurrence": {
"schedule": [
{
"days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"timeAndCapacity": {
"maxInstanceCount": 3,
"minInstanceCount": 3,
"time": "09:00",
},
},
{
"days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"timeAndCapacity": {
"maxInstanceCount": 6,
"minInstanceCount": 6,
"time": "18:00",
},
},
{
"days": ["Saturday", "Sunday"],
"timeAndCapacity": {
"maxInstanceCount": 2,
"minInstanceCount": 2,
"time": "09:00",
},
},
{
"days": ["Saturday", "Sunday"],
"timeAndCapacity": {
"maxInstanceCount": 4,
"minInstanceCount": 4,
"time": "18:00",
},
},
],
"timeZone": "China Standard Time",
},
},
"dataDisksGroups": None,
"hardwareProfile": {"vmSize": "Standard_D4_V2"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"scriptActions": [],
"targetInstanceCount": 4,
"virtualNetworkProfile": None,
}
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "hdinsight-autoscale-tes-2019-06-18t05-49-16-591z",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAutoscaleConfig.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAutoscaleConfig.json
func ExampleClustersClient_BeginCreate_createHdInsightClusterWithAutoscaleConfiguration() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
ComponentVersion: map[string]*string{
"Hadoop": to.Ptr("2.7"),
},
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("hadoop"),
},
ClusterVersion: to.Ptr("3.6"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("workernode"),
AutoscaleConfiguration: &armhdinsight.Autoscale{
Recurrence: &armhdinsight.AutoscaleRecurrence{
Schedule: []*armhdinsight.AutoscaleSchedule{
{
Days: []*armhdinsight.DaysOfWeek{
to.Ptr(armhdinsight.DaysOfWeekMonday),
to.Ptr(armhdinsight.DaysOfWeekTuesday),
to.Ptr(armhdinsight.DaysOfWeekWednesday),
to.Ptr(armhdinsight.DaysOfWeekThursday),
to.Ptr(armhdinsight.DaysOfWeekFriday)},
TimeAndCapacity: &armhdinsight.AutoscaleTimeAndCapacity{
MaxInstanceCount: to.Ptr[int32](3),
MinInstanceCount: to.Ptr[int32](3),
Time: to.Ptr("09:00"),
},
},
{
Days: []*armhdinsight.DaysOfWeek{
to.Ptr(armhdinsight.DaysOfWeekMonday),
to.Ptr(armhdinsight.DaysOfWeekTuesday),
to.Ptr(armhdinsight.DaysOfWeekWednesday),
to.Ptr(armhdinsight.DaysOfWeekThursday),
to.Ptr(armhdinsight.DaysOfWeekFriday)},
TimeAndCapacity: &armhdinsight.AutoscaleTimeAndCapacity{
MaxInstanceCount: to.Ptr[int32](6),
MinInstanceCount: to.Ptr[int32](6),
Time: to.Ptr("18:00"),
},
},
{
Days: []*armhdinsight.DaysOfWeek{
to.Ptr(armhdinsight.DaysOfWeekSaturday),
to.Ptr(armhdinsight.DaysOfWeekSunday)},
TimeAndCapacity: &armhdinsight.AutoscaleTimeAndCapacity{
MaxInstanceCount: to.Ptr[int32](2),
MinInstanceCount: to.Ptr[int32](2),
Time: to.Ptr("09:00"),
},
},
{
Days: []*armhdinsight.DaysOfWeek{
to.Ptr(armhdinsight.DaysOfWeekSaturday),
to.Ptr(armhdinsight.DaysOfWeekSunday)},
TimeAndCapacity: &armhdinsight.AutoscaleTimeAndCapacity{
MaxInstanceCount: to.Ptr[int32](4),
MinInstanceCount: to.Ptr[int32](4),
Time: to.Ptr("18:00"),
},
}},
TimeZone: to.Ptr("China Standard Time"),
},
},
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D4_V2"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
ScriptActions: []*armhdinsight.ScriptAction{},
TargetInstanceCount: to.Ptr[int32](4),
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("hdinsight-autoscale-tes-2019-06-18t05-49-16-591z"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("East US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("3.1"),
// },
// Kind: to.Ptr("HADOOP"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d12_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-18T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](40),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAutoscaleConfig.json
*/
async function createHdInsightClusterWithAutoscaleConfiguration() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
componentVersion: { hadoop: "2.7" },
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "hadoop",
},
clusterVersion: "3.6",
computeProfile: {
roles: [
{
name: "workernode",
autoscaleConfiguration: {
capacity: {},
recurrence: {
schedule: [
{
days: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
timeAndCapacity: {
maxInstanceCount: 3,
minInstanceCount: 3,
time: "09:00",
},
},
{
days: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
timeAndCapacity: {
maxInstanceCount: 6,
minInstanceCount: 6,
time: "18:00",
},
},
{
days: ["Saturday", "Sunday"],
timeAndCapacity: {
maxInstanceCount: 2,
minInstanceCount: 2,
time: "09:00",
},
},
{
days: ["Saturday", "Sunday"],
timeAndCapacity: {
maxInstanceCount: 4,
minInstanceCount: 4,
time: "18:00",
},
},
],
timeZone: "China Standard Time",
},
},
dataDisksGroups: [],
hardwareProfile: { vmSize: "Standard_D4_V2" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
scriptActions: [],
targetInstanceCount: 4,
virtualNetworkProfile: {},
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "hdinsight-autoscale-tes-2019-06-18t05-49-16-591z",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateHDInsightClusterWithAutoscaleConfig.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.6",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "hadoop",
ComponentVersion =
{
["Hadoop"] = "2.7",
},
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 4,
AutoScaleConfiguration = new HDInsightAutoScaleConfiguration()
{
Capacity = null,
Recurrence = new HDInsightAutoScaleRecurrence()
{
TimeZone = "China Standard Time",
Schedule =
{
new HDInsightAutoScaleSchedule()
{
Days =
{
HDInsightDayOfWeek.Monday,HDInsightDayOfWeek.Tuesday,HDInsightDayOfWeek.Wednesday,HDInsightDayOfWeek.Thursday,HDInsightDayOfWeek.Friday
},
TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity()
{
Time = "09:00",
MinInstanceCount = 3,
MaxInstanceCount = 3,
},
},new HDInsightAutoScaleSchedule()
{
Days =
{
HDInsightDayOfWeek.Monday,HDInsightDayOfWeek.Tuesday,HDInsightDayOfWeek.Wednesday,HDInsightDayOfWeek.Thursday,HDInsightDayOfWeek.Friday
},
TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity()
{
Time = "18:00",
MinInstanceCount = 6,
MaxInstanceCount = 6,
},
},new HDInsightAutoScaleSchedule()
{
Days =
{
HDInsightDayOfWeek.Saturday,HDInsightDayOfWeek.Sunday
},
TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity()
{
Time = "09:00",
MinInstanceCount = 2,
MaxInstanceCount = 2,
},
},new HDInsightAutoScaleSchedule()
{
Days =
{
HDInsightDayOfWeek.Saturday,HDInsightDayOfWeek.Sunday
},
TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity()
{
Time = "18:00",
MinInstanceCount = 4,
MaxInstanceCount = 4,
},
}
},
},
},
HardwareVmSize = "Standard_D4_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
VirtualNetworkProfile = null,
DataDisksGroups =
{
},
ScriptActions =
{
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "hdinsight-autoscale-tes-2019-06-18t05-49-16-591z",
Key = "storagekey",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "East US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json",
"kind": "HADOOP",
"componentVersion": {
"Hadoop": "3.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d12_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-18T12:25:43.48",
"quotaInfo": {
"coresUsed": 40
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard"
}
}
Create Kafka cluster with Kafka Rest Proxy
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"properties": {
"clusterVersion": "4.0",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "kafka",
"componentVersion": {
"Kafka": "2.1"
},
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"kafkaRestProperties": {
"clientGroupInfo": {
"groupName": "Kafka security group name",
"groupId": "00000000-0000-0000-0000-111111111111"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Large"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
},
"dataDisksGroups": [
{
"disksPerNode": 8
}
]
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "kafkamanagementnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_D4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "kafkauser",
"password": "**********"
}
}
}
]
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "containername",
"key": "storagekey"
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClientGroupInfo;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.DataDisksGroups;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.KafkaRestProperties;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateKafkaClusterWithKafkaRestProxy.json
*/
/**
* Sample code: Create Kafka cluster with Kafka Rest Proxy.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createKafkaClusterWithKafkaRestProxy(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("4.0")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("kafka")
.withComponentVersion(mapOf("Kafka", "2.1"))
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withKafkaRestProperties(
new KafkaRestProperties()
.withClientGroupInfo(
new ClientGroupInfo()
.withGroupName("Kafka security group name")
.withGroupId("00000000-0000-0000-0000-111111111111")))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Large"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Large"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")))
.withDataDisksGroups(
Arrays.asList(new DataDisksGroups().withDisksPerNode(8))),
new Role()
.withName("zookeepernode")
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("kafkamanagementnode")
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D4_v2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("kafkauser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_kafka_cluster_with_kafka_rest_proxy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"componentVersion": {"Kafka": "2.1"},
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "kafka",
},
"clusterVersion": "4.0",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Large"},
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"dataDisksGroups": [{"disksPerNode": 8}],
"hardwareProfile": {"vmSize": "Large"},
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
{
"hardwareProfile": {"vmSize": "Small"},
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 3,
},
{
"hardwareProfile": {"vmSize": "Standard_D4_v2"},
"name": "kafkamanagementnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "kafkauser"}
},
"targetInstanceCount": 2,
},
]
},
"kafkaRestProperties": {
"clientGroupInfo": {
"groupId": "00000000-0000-0000-0000-111111111111",
"groupName": "Kafka security group name",
}
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storagekey",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
}
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateKafkaClusterWithKafkaRestProxy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateKafkaClusterWithKafkaRestProxy.json
func ExampleClustersClient_BeginCreate_createKafkaClusterWithKafkaRestProxy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
ComponentVersion: map[string]*string{
"Kafka": to.Ptr("2.1"),
},
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("kafka"),
},
ClusterVersion: to.Ptr("4.0"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Large"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
DataDisksGroups: []*armhdinsight.DataDisksGroups{
{
DisksPerNode: to.Ptr[int32](8),
}},
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Large"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](3),
},
{
Name: to.Ptr("kafkamanagementnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D4_v2"),
},
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("kafkauser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
}},
},
KafkaRestProperties: &armhdinsight.KafkaRestProperties{
ClientGroupInfo: &armhdinsight.ClientGroupInfo{
GroupID: to.Ptr("00000000-0000-0000-0000-111111111111"),
GroupName: to.Ptr("Kafka security group name"),
},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storagekey"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("South Central US"),
// Etag: to.Ptr("e1266b83-9bda-4797-a906-1bf82c8eb09a"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/kafka-4.0.1000.1.1911212244.json"),
// ComponentVersion: map[string]*string{
// "Kafka": to.Ptr("2.1"),
// },
// Kind: to.Ptr("KAFKA"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// DataDisksGroups: []*armhdinsight.DataDisksGroups{
// {
// DiskSizeGB: to.Ptr[int32](1023),
// DisksPerNode: to.Ptr[int32](2),
// StorageAccountType: to.Ptr("Standard_LRS"),
// }},
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d3_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("kafkamanagementnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("KafkaRestProxyPublicEndpoint"),
// Location: to.Ptr("cluster1-kafkarest.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-25T03:43:23.663"),
// KafkaRestProperties: &armhdinsight.KafkaRestProperties{
// ClientGroupInfo: &armhdinsight.ClientGroupInfo{
// GroupID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// GroupName: to.Ptr("security group name"),
// },
// },
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](52),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateKafkaClusterWithKafkaRestProxy.json
*/
async function createKafkaClusterWithKafkaRestProxy() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
componentVersion: { kafka: "2.1" },
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "kafka",
},
clusterVersion: "4.0",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Large" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
dataDisksGroups: [{ disksPerNode: 8 }],
hardwareProfile: { vmSize: "Large" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 3,
},
{
name: "kafkamanagementnode",
hardwareProfile: { vmSize: "Standard_D4_v2" },
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "kafkauser",
},
},
targetInstanceCount: 2,
},
],
},
kafkaRestProperties: {
clientGroupInfo: {
groupId: "00000000-0000-0000-0000-111111111111",
groupName: "Kafka security group name",
},
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "containername",
isDefault: true,
key: "storagekey",
},
],
},
tier: "Standard",
},
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateKafkaClusterWithKafkaRestProxy.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "4.0",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "kafka",
ComponentVersion =
{
["Kafka"] = "2.1",
},
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
KafkaRestProperties = new KafkaRestProperties()
{
ClientGroupInfo = new ClientGroupInfo()
{
GroupName = "Kafka security group name",
GroupId = "00000000-0000-0000-0000-111111111111",
},
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
TargetInstanceCount = 2,
HardwareVmSize = "Large",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
TargetInstanceCount = 3,
HardwareVmSize = "Large",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
DataDisksGroups =
{
new HDInsightClusterDataDiskGroup()
{
DisksPerNode = 8,
}
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "kafkamanagementnode",
TargetInstanceCount = 2,
HardwareVmSize = "Standard_D4_v2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "kafkauser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "containername",
Key = "storagekey",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "South Central US",
"etag": "e1266b83-9bda-4797-a906-1bf82c8eb09a",
"tags": null,
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/kafka-4.0.1000.1.1911212244.json",
"kind": "KAFKA",
"componentVersion": {
"Kafka": "2.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d3_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d3_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
},
"dataDisksGroups": [
{
"disksPerNode": 2,
"storageAccountType": "Standard_LRS",
"diskSizeGB": 1023
}
]
},
{
"name": "kafkamanagementnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-25T03:43:23.663",
"quotaInfo": {
"coresUsed": 52
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
},
{
"name": "KafkaRestProxyPublicEndpoint",
"protocol": "TCP",
"location": "cluster1-kafkarest.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard",
"kafkaRestProperties": {
"clientGroupInfo": {
"groupName": "security group name",
"groupId": "00000000-0000-0000-0000-000000000000"
}
}
}
}
Create Secure Hadoop cluster
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"tags": {
"key1": "val1"
},
"properties": {
"clusterVersion": "3.5",
"osType": "Linux",
"tier": "Premium",
"clusterDefinition": {
"kind": "Hadoop",
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "containername",
"key": "storage account key"
}
]
},
"securityProfile": {
"directoryType": "ActiveDirectory",
"domain": "DomainName",
"organizationalUnitDN": "OU=Hadoop,DC=hdinsight,DC=test",
"ldapsUrls": [
"ldaps://10.10.0.4:636"
],
"domainUsername": "DomainUsername",
"domainUserPassword": "**********",
"clusterUsersGroupDNs": [
"hdiusers"
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"minInstanceCount": 1,
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
},
"scriptActions": []
},
{
"name": "workernode",
"minInstanceCount": 1,
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "Standard_D3_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
},
"scriptActions": []
},
{
"name": "zookeepernode",
"minInstanceCount": 1,
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "Small"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********",
"sshProfile": {
"publicKeys": [
{
"certificateData": "**********"
}
]
}
}
},
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"
},
"scriptActions": []
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.DirectoryType;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.SecurityProfile;
import com.azure.resourcemanager.hdinsight.models.SshProfile;
import com.azure.resourcemanager.hdinsight.models.SshPublicKey;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import com.azure.resourcemanager.hdinsight.models.VirtualNetworkProfile;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSecureHadoop.json
*/
/**
* Sample code: Create Secure Hadoop cluster.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createSecureHadoopCluster(com.azure.resourcemanager.hdinsight.HDInsightManager manager)
throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withTags(mapOf("key1", "val1"))
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.5")
.withOsType(OSType.LINUX)
.withTier(Tier.PREMIUM)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Hadoop")
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withSecurityProfile(
new SecurityProfile()
.withDirectoryType(DirectoryType.ACTIVE_DIRECTORY)
.withDomain("DomainName")
.withOrganizationalUnitDN("OU=Hadoop,DC=hdinsight,DC=test")
.withLdapsUrls(Arrays.asList("ldaps://10.10.0.4:636"))
.withDomainUsername("DomainUsername")
.withDomainUserPassword("fakeTokenPlaceholder")
.withClusterUsersGroupDNs(Arrays.asList("hdiusers")))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withMinInstanceCount(1)
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"))
.withScriptActions(Arrays.asList()),
new Role()
.withName("workernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(4)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D3_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"))
.withScriptActions(Arrays.asList()),
new Role()
.withName("zookeepernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(3)
.withHardwareProfile(new HardwareProfile().withVmSize("Small"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder")
.withSshProfile(
new SshProfile()
.withPublicKeys(
Arrays
.asList(
new SshPublicKey()
.withCertificateData(
"**********"))))))
.withVirtualNetworkProfile(
new VirtualNetworkProfile()
.withId(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname")
.withSubnet(
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"))
.withScriptActions(Arrays.asList()))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_linux_hadoop_secure_hadoop.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Hadoop",
},
"clusterVersion": "3.5",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"scriptActions": [],
"targetInstanceCount": 2,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
"hardwareProfile": {"vmSize": "Standard_D3_V2"},
"minInstanceCount": 1,
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"scriptActions": [],
"targetInstanceCount": 4,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
"hardwareProfile": {"vmSize": "Small"},
"minInstanceCount": 1,
"name": "zookeepernode",
"osProfile": {
"linuxOperatingSystemProfile": {
"password": "**********",
"sshProfile": {"publicKeys": [{"certificateData": "**********"}]},
"username": "sshuser",
}
},
"scriptActions": [],
"targetInstanceCount": 3,
"virtualNetworkProfile": {
"id": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
"subnet": "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
]
},
"osType": "Linux",
"securityProfile": {
"clusterUsersGroupDNs": ["hdiusers"],
"directoryType": "ActiveDirectory",
"domain": "DomainName",
"domainUserPassword": "**********",
"domainUsername": "DomainUsername",
"ldapsUrls": ["ldaps://10.10.0.4:636"],
"organizationalUnitDN": "OU=Hadoop,DC=hdinsight,DC=test",
},
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storage account key",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Premium",
},
"tags": {"key1": "val1"},
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSecureHadoop.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSecureHadoop.json
func ExampleClustersClient_BeginCreate_createSecureHadoopCluster() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Hadoop"),
},
ClusterVersion: to.Ptr("3.5"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
ScriptActions: []*armhdinsight.ScriptAction{},
TargetInstanceCount: to.Ptr[int32](2),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D3_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
ScriptActions: []*armhdinsight.ScriptAction{},
TargetInstanceCount: to.Ptr[int32](4),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
},
{
Name: to.Ptr("zookeepernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Small"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
SSHProfile: &armhdinsight.SSHProfile{
PublicKeys: []*armhdinsight.SSHPublicKey{
{
CertificateData: to.Ptr("**********"),
}},
},
Username: to.Ptr("sshuser"),
},
},
ScriptActions: []*armhdinsight.ScriptAction{},
TargetInstanceCount: to.Ptr[int32](3),
VirtualNetworkProfile: &armhdinsight.VirtualNetworkProfile{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet"),
},
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
SecurityProfile: &armhdinsight.SecurityProfile{
ClusterUsersGroupDNs: []*string{
to.Ptr("hdiusers")},
DirectoryType: to.Ptr(armhdinsight.DirectoryTypeActiveDirectory),
Domain: to.Ptr("DomainName"),
DomainUserPassword: to.Ptr("**********"),
DomainUsername: to.Ptr("DomainUsername"),
LdapsUrls: []*string{
to.Ptr("ldaps://10.10.0.4:636")},
OrganizationalUnitDN: to.Ptr("OU=Hadoop,DC=hdinsight,DC=test"),
},
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storage account key"),
}},
},
Tier: to.Ptr(armhdinsight.TierPremium),
},
Tags: map[string]*string{
"key1": to.Ptr("val1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("East US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("3.1"),
// },
// Kind: to.Ptr("HADOOP"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d12_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-18T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](40),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSecureHadoop.json
*/
async function createSecureHadoopCluster() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Hadoop",
},
clusterVersion: "3.5",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
scriptActions: [],
targetInstanceCount: 2,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
name: "workernode",
hardwareProfile: { vmSize: "Standard_D3_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
scriptActions: [],
targetInstanceCount: 4,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
{
name: "zookeepernode",
hardwareProfile: { vmSize: "Small" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
sshProfile: { publicKeys: [{ certificateData: "**********" }] },
username: "sshuser",
},
},
scriptActions: [],
targetInstanceCount: 3,
virtualNetworkProfile: {
id: "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname",
subnet:
"/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
},
],
},
osType: "Linux",
securityProfile: {
clusterUsersGroupDNs: ["hdiusers"],
directoryType: "ActiveDirectory",
domain: "DomainName",
domainUserPassword: "**********",
domainUsername: "DomainUsername",
ldapsUrls: ["ldaps://10.10.0.4:636"],
organizationalUnitDN: "OU=Hadoop,DC=hdinsight,DC=test",
},
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "containername",
isDefault: true,
key: "storage account key",
},
],
},
tier: "Premium",
},
tags: { key1: "val1" },
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxHadoopSecureHadoop.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Tags =
{
["key1"] = "val1",
},
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.5",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Premium,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Hadoop",
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
SecurityProfile = new HDInsightSecurityProfile()
{
DirectoryType = AuthenticationDirectoryType.ActiveDirectory,
Domain = "DomainName",
OrganizationalUnitDN = "OU=Hadoop,DC=hdinsight,DC=test",
LdapUris =
{
new Uri("ldaps://10.10.0.4:636")
},
DomainUsername = "DomainUsername",
DomainUserPassword = "**********",
ClusterUsersGroupDNs =
{
"hdiusers"
},
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
MinInstanceCount = 1,
TargetInstanceCount = 2,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
ScriptActions =
{
},
},new HDInsightClusterRole()
{
Name = "workernode",
MinInstanceCount = 1,
TargetInstanceCount = 4,
HardwareVmSize = "Standard_D3_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
ScriptActions =
{
},
},new HDInsightClusterRole()
{
Name = "zookeepernode",
MinInstanceCount = 1,
TargetInstanceCount = 3,
HardwareVmSize = "Small",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
SshPublicKeys =
{
new HDInsightSshPublicKey()
{
CertificateData = "**********",
}
},
},
VirtualNetworkProfile = new HDInsightVirtualNetworkProfile()
{
Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"),
Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet",
},
ScriptActions =
{
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "containername",
Key = "storage account key",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "East US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json",
"kind": "HADOOP",
"componentVersion": {
"Hadoop": "3.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d12_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-18T12:25:43.48",
"quotaInfo": {
"coresUsed": 40
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard"
}
}
Create Spark on Linux Cluster with SSH password
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1?api-version=2021-06-01
{
"tags": {
"key1": "val1"
},
"properties": {
"clusterVersion": "3.5",
"osType": "Linux",
"tier": "Standard",
"clusterDefinition": {
"kind": "Spark",
"componentVersion": {
"Spark": "2.0"
},
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": true,
"restAuthCredential.username": "admin",
"restAuthCredential.password": "**********"
}
}
},
"storageProfile": {
"storageaccounts": [
{
"name": "mystorage.blob.core.windows.net",
"isDefault": true,
"container": "containername",
"key": "storageapikey*"
}
]
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"minInstanceCount": 1,
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "Standard_D12_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
},
{
"name": "workernode",
"minInstanceCount": 1,
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "Standard_D4_V2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser",
"password": "**********"
}
}
}
]
}
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.hdinsight.models.ClusterCreateProperties;
import com.azure.resourcemanager.hdinsight.models.ClusterDefinition;
import com.azure.resourcemanager.hdinsight.models.ComputeProfile;
import com.azure.resourcemanager.hdinsight.models.HardwareProfile;
import com.azure.resourcemanager.hdinsight.models.LinuxOperatingSystemProfile;
import com.azure.resourcemanager.hdinsight.models.OSType;
import com.azure.resourcemanager.hdinsight.models.OsProfile;
import com.azure.resourcemanager.hdinsight.models.Role;
import com.azure.resourcemanager.hdinsight.models.StorageAccount;
import com.azure.resourcemanager.hdinsight.models.StorageProfile;
import com.azure.resourcemanager.hdinsight.models.Tier;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** Samples for Clusters Create. */
public final class Main {
/*
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxSparkSshPassword.json
*/
/**
* Sample code: Create Spark on Linux Cluster with SSH password.
*
* @param manager Entry point to HDInsightManager.
*/
public static void createSparkOnLinuxClusterWithSSHPassword(
com.azure.resourcemanager.hdinsight.HDInsightManager manager) throws IOException {
manager
.clusters()
.define("cluster1")
.withExistingResourceGroup("rg1")
.withTags(mapOf("key1", "val1"))
.withProperties(
new ClusterCreateProperties()
.withClusterVersion("3.5")
.withOsType(OSType.LINUX)
.withTier(Tier.STANDARD)
.withClusterDefinition(
new ClusterDefinition()
.withKind("Spark")
.withComponentVersion(mapOf("Spark", "2.0"))
.withConfigurations(
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize(
"{\"gateway\":{\"restAuthCredential.isEnabled\":true,\"restAuthCredential.password\":\"**********\",\"restAuthCredential.username\":\"admin\"}}",
Object.class,
SerializerEncoding.JSON)))
.withComputeProfile(
new ComputeProfile()
.withRoles(
Arrays
.asList(
new Role()
.withName("headnode")
.withMinInstanceCount(1)
.withTargetInstanceCount(2)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D12_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))),
new Role()
.withName("workernode")
.withMinInstanceCount(1)
.withTargetInstanceCount(4)
.withHardwareProfile(new HardwareProfile().withVmSize("Standard_D4_V2"))
.withOsProfile(
new OsProfile()
.withLinuxOperatingSystemProfile(
new LinuxOperatingSystemProfile()
.withUsername("sshuser")
.withPassword("fakeTokenPlaceholder"))))))
.withStorageProfile(
new StorageProfile()
.withStorageaccounts(
Arrays
.asList(
new StorageAccount()
.withName("mystorage.blob.core.windows.net")
.withIsDefault(true)
.withContainer("containername")
.withKey("fakeTokenPlaceholder")))))
.create();
}
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.hdinsight import HDInsightManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-hdinsight
# USAGE
python create_linux_spark_ssh_password.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = HDInsightManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.clusters.begin_create(
resource_group_name="rg1",
cluster_name="cluster1",
parameters={
"properties": {
"clusterDefinition": {
"componentVersion": {"Spark": "2.0"},
"configurations": {
"gateway": {
"restAuthCredential.isEnabled": True,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
}
},
"kind": "Spark",
},
"clusterVersion": "3.5",
"computeProfile": {
"roles": [
{
"hardwareProfile": {"vmSize": "Standard_D12_V2"},
"minInstanceCount": 1,
"name": "headnode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 2,
},
{
"hardwareProfile": {"vmSize": "Standard_D4_V2"},
"minInstanceCount": 1,
"name": "workernode",
"osProfile": {
"linuxOperatingSystemProfile": {"password": "**********", "username": "sshuser"}
},
"targetInstanceCount": 4,
},
]
},
"osType": "Linux",
"storageProfile": {
"storageaccounts": [
{
"container": "containername",
"isDefault": True,
"key": "storageapikey*",
"name": "mystorage.blob.core.windows.net",
}
]
},
"tier": "Standard",
},
"tags": {"key1": "val1"},
},
).result()
print(response)
# x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxSparkSshPassword.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armhdinsight_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hdinsight/armhdinsight"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxSparkSshPassword.json
func ExampleClustersClient_BeginCreate_createSparkOnLinuxClusterWithSshPassword() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armhdinsight.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClustersClient().BeginCreate(ctx, "rg1", "cluster1", armhdinsight.ClusterCreateParametersExtended{
Properties: &armhdinsight.ClusterCreateProperties{
ClusterDefinition: &armhdinsight.ClusterDefinition{
ComponentVersion: map[string]*string{
"Spark": to.Ptr("2.0"),
},
Configurations: map[string]any{
"gateway": map[string]any{
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
Kind: to.Ptr("Spark"),
},
ClusterVersion: to.Ptr("3.5"),
ComputeProfile: &armhdinsight.ComputeProfile{
Roles: []*armhdinsight.Role{
{
Name: to.Ptr("headnode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D12_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](2),
},
{
Name: to.Ptr("workernode"),
HardwareProfile: &armhdinsight.HardwareProfile{
VMSize: to.Ptr("Standard_D4_V2"),
},
MinInstanceCount: to.Ptr[int32](1),
OSProfile: &armhdinsight.OsProfile{
LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
Password: to.Ptr("**********"),
Username: to.Ptr("sshuser"),
},
},
TargetInstanceCount: to.Ptr[int32](4),
}},
},
OSType: to.Ptr(armhdinsight.OSTypeLinux),
StorageProfile: &armhdinsight.StorageProfile{
Storageaccounts: []*armhdinsight.StorageAccount{
{
Name: to.Ptr("mystorage.blob.core.windows.net"),
Container: to.Ptr("containername"),
IsDefault: to.Ptr(true),
Key: to.Ptr("storageapikey*"),
}},
},
Tier: to.Ptr(armhdinsight.TierStandard),
},
Tags: map[string]*string{
"key1": to.Ptr("val1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Cluster = armhdinsight.Cluster{
// Name: to.Ptr("cluster1"),
// Type: to.Ptr("Microsoft.HDInsight/clusters"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1"),
// Location: to.Ptr("East US"),
// Etag: to.Ptr("fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff"),
// Properties: &armhdinsight.ClusterGetProperties{
// ClusterDefinition: &armhdinsight.ClusterDefinition{
// Blueprint: to.Ptr("https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json"),
// ComponentVersion: map[string]*string{
// "Hadoop": to.Ptr("3.1"),
// },
// Kind: to.Ptr("SPARK"),
// },
// ClusterState: to.Ptr("Running"),
// ClusterVersion: to.Ptr("4.0.1000.1"),
// ComputeProfile: &armhdinsight.ComputeProfile{
// Roles: []*armhdinsight.Role{
// {
// Name: to.Ptr("headnode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d12_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](2),
// },
// {
// Name: to.Ptr("workernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_d4_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](4),
// },
// {
// Name: to.Ptr("zookeepernode"),
// HardwareProfile: &armhdinsight.HardwareProfile{
// VMSize: to.Ptr("standard_a2_v2"),
// },
// OSProfile: &armhdinsight.OsProfile{
// LinuxOperatingSystemProfile: &armhdinsight.LinuxOperatingSystemProfile{
// Username: to.Ptr("sshuser"),
// },
// },
// TargetInstanceCount: to.Ptr[int32](3),
// }},
// },
// ConnectivityEndpoints: []*armhdinsight.ConnectivityEndpoint{
// {
// Name: to.Ptr("SSH"),
// Location: to.Ptr("cluster1-ssh.azurehdinsight.net"),
// Port: to.Ptr[int32](22),
// Protocol: to.Ptr("TCP"),
// },
// {
// Name: to.Ptr("HTTPS"),
// Location: to.Ptr("cluster1.azurehdinsight.net"),
// Port: to.Ptr[int32](443),
// Protocol: to.Ptr("TCP"),
// }},
// CreatedDate: to.Ptr("2019-11-18T12:25:43.48"),
// OSType: to.Ptr(armhdinsight.OSTypeLinux),
// ProvisioningState: to.Ptr(armhdinsight.HDInsightClusterProvisioningStateSucceeded),
// QuotaInfo: &armhdinsight.QuotaInfo{
// CoresUsed: to.Ptr[int32](40),
// },
// Tier: to.Ptr(armhdinsight.TierStandard),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { HDInsightManagementClient } = require("@azure/arm-hdinsight");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates a new HDInsight cluster with the specified parameters.
*
* @summary Creates a new HDInsight cluster with the specified parameters.
* x-ms-original-file: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxSparkSshPassword.json
*/
async function createSparkOnLinuxClusterWithSshPassword() {
const subscriptionId = process.env["HDINSIGHT_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["HDINSIGHT_RESOURCE_GROUP"] || "rg1";
const clusterName = "cluster1";
const parameters = {
properties: {
clusterDefinition: {
componentVersion: { spark: "2.0" },
configurations: {
gateway: {
"restAuthCredential.isEnabled": true,
"restAuthCredential.password": "**********",
"restAuthCredential.username": "admin",
},
},
kind: "Spark",
},
clusterVersion: "3.5",
computeProfile: {
roles: [
{
name: "headnode",
hardwareProfile: { vmSize: "Standard_D12_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 2,
},
{
name: "workernode",
hardwareProfile: { vmSize: "Standard_D4_V2" },
minInstanceCount: 1,
osProfile: {
linuxOperatingSystemProfile: {
password: "**********",
username: "sshuser",
},
},
targetInstanceCount: 4,
},
],
},
osType: "Linux",
storageProfile: {
storageaccounts: [
{
name: "mystorage.blob.core.windows.net",
container: "containername",
isDefault: true,
key: "storageapikey*",
},
],
},
tier: "Standard",
},
tags: { key1: "val1" },
};
const credential = new DefaultAzureCredential();
const client = new HDInsightManagementClient(credential, subscriptionId);
const result = await client.clusters.beginCreateAndWait(
resourceGroupName,
clusterName,
parameters
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.HDInsight;
using Azure.ResourceManager.HDInsight.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/stable/2021-06-01/examples/CreateLinuxSparkSshPassword.json
// this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this HDInsightClusterResource
HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters();
// invoke the operation
string clusterName = "cluster1";
HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent()
{
Tags =
{
["key1"] = "val1",
},
Properties = new HDInsightClusterCreateOrUpdateProperties()
{
ClusterVersion = "3.5",
OSType = HDInsightOSType.Linux,
Tier = HDInsightTier.Standard,
ClusterDefinition = new HDInsightClusterDefinition()
{
Kind = "Spark",
ComponentVersion =
{
["Spark"] = "2.0",
},
Configurations = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
{
["gateway"] = new Dictionary<string, object>()
{
["restAuthCredential.isEnabled"] = "true",
["restAuthCredential.password"] = "**********",
["restAuthCredential.username"] = "admin"
}
}),
},
ComputeRoles =
{
new HDInsightClusterRole()
{
Name = "headnode",
MinInstanceCount = 1,
TargetInstanceCount = 2,
HardwareVmSize = "Standard_D12_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
},new HDInsightClusterRole()
{
Name = "workernode",
MinInstanceCount = 1,
TargetInstanceCount = 4,
HardwareVmSize = "Standard_D4_V2",
OSLinuxProfile = new HDInsightLinuxOSProfile()
{
Username = "sshuser",
Password = "**********",
},
}
},
StorageAccounts =
{
new HDInsightStorageAccountInfo()
{
Name = "mystorage.blob.core.windows.net",
IsDefault = true,
Container = "containername",
Key = "storageapikey*",
}
},
},
};
ArmOperation<HDInsightClusterResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content);
HDInsightClusterResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
HDInsightClusterData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
location: https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1/azureasyncoperations/create?api-version=2021-06-01
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.HDInsight/clusters/cluster1",
"name": "cluster1",
"type": "Microsoft.HDInsight/clusters",
"location": "East US",
"etag": "fdf2a6e8-ce83-42cc-8c2d-0ceb11a370ff",
"properties": {
"clusterVersion": "4.0.1000.1",
"osType": "Linux",
"clusterDefinition": {
"blueprint": "https://blueprints.azurehdinsight.net/hadoop-4.0.1000.1.1910270459.json",
"kind": "SPARK",
"componentVersion": {
"Hadoop": "3.1"
}
},
"computeProfile": {
"roles": [
{
"name": "headnode",
"targetInstanceCount": 2,
"hardwareProfile": {
"vmSize": "standard_d12_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "workernode",
"targetInstanceCount": 4,
"hardwareProfile": {
"vmSize": "standard_d4_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
},
{
"name": "zookeepernode",
"targetInstanceCount": 3,
"hardwareProfile": {
"vmSize": "standard_a2_v2"
},
"osProfile": {
"linuxOperatingSystemProfile": {
"username": "sshuser"
}
}
}
]
},
"provisioningState": "Succeeded",
"clusterState": "Running",
"createdDate": "2019-11-18T12:25:43.48",
"quotaInfo": {
"coresUsed": 40
},
"connectivityEndpoints": [
{
"name": "SSH",
"protocol": "TCP",
"location": "cluster1-ssh.azurehdinsight.net",
"port": 22
},
{
"name": "HTTPS",
"protocol": "TCP",
"location": "cluster1.azurehdinsight.net",
"port": 443
}
],
"tier": "Standard"
}
}
定义
Autoscale
Object
自动缩放请求参数
AutoscaleCapacity
Object
基于负载的自动缩放请求参数
| 名称 |
类型 |
说明 |
|
maxInstanceCount
|
integer
(int32)
|
群集的最大实例计数
|
|
minInstanceCount
|
integer
(int32)
|
群集的最小实例计数
|
AutoscaleRecurrence
Object
基于计划的自动缩放请求参数
AutoscaleSchedule
Object
基于计划的自动缩放规则的参数,由天数数组 + 时间和容量组成
AutoscaleTimeAndCapacity
Object
时间和容量请求参数
| 名称 |
类型 |
说明 |
|
maxInstanceCount
|
integer
(int32)
|
群集的最大实例计数
|
|
minInstanceCount
|
integer
(int32)
|
群集的最小实例计数
|
|
time
|
string
|
格式为 xx:xx 的 24 小时时间
|
ClientGroupInfo
Object
AAD 安全组的信息。
| 名称 |
类型 |
说明 |
|
groupId
|
string
|
AAD 安全组 ID。
|
|
groupName
|
string
|
AAD 安全组名称。
|
Cluster
Object
HDInsight 群集。
| 名称 |
类型 |
说明 |
|
etag
|
string
|
资源的 ETag
|
|
id
|
string
|
资源的完全限定资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
identity
|
ClusterIdentity
|
群集的标识(如果已配置)。
|
|
location
|
string
|
资源所在的地理位置
|
|
name
|
string
|
资源的名称
|
|
properties
|
ClusterGetProperties
|
群集的属性。
|
|
systemData
|
systemData
|
与创建和上次修改资源相关的元数据。
|
|
tags
|
object
|
资源标记。
|
|
type
|
string
|
资源的类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
|
zones
|
string[]
|
可用性区域。
|
ClusterCreateParametersExtended
Object
CreateCluster 请求参数。
ClusterCreateProperties
Object
群集创建参数。
ClusterDefinition
Object
群集定义。
| 名称 |
类型 |
说明 |
|
blueprint
|
string
|
指向蓝图的链接。
|
|
componentVersion
|
object
|
群集中不同服务的版本。
|
|
configurations
|
object
|
群集配置。
|
|
kind
|
string
|
群集的类型。
|
ClusterGetProperties
Object
群集的属性。
ClusterIdentity
Object
群集的标识。
| 名称 |
类型 |
说明 |
|
principalId
|
string
|
群集标识的主体 ID。 此属性仅针对系统分配的标识提供。
|
|
tenantId
|
string
|
与群集关联的租户 ID。 此属性仅针对系统分配的标识提供。
|
|
type
|
ResourceIdentityType
|
用于群集的标识类型。 类型“SystemAssigned,UserAssigned”包括隐式创建的标识和一组用户分配的标识。
|
|
userAssignedIdentities
|
<string,
UserAssignedIdentity>
|
与群集关联的用户标识列表。 用户标识字典密钥引用的格式为 ARM 资源 ID:“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。
|
ComputeIsolationProperties
Object
计算隔离属性。
| 名称 |
类型 |
默认值 |
说明 |
|
enableComputeIsolation
|
boolean
|
False
|
该标志指示是否启用计算隔离。
|
|
hostSku
|
string
|
|
主机 SKU。
|
ComputeProfile
Object
描述计算配置文件。
| 名称 |
类型 |
说明 |
|
roles
|
Role[]
|
群集中的角色列表。
|
ConnectivityEndpoint
Object
连接属性
| 名称 |
类型 |
说明 |
|
location
|
string
|
终结点的位置。
|
|
name
|
string
|
终结点的名称。
|
|
port
|
integer
(int32)
|
要连接到的端口。
|
|
privateIPAddress
|
string
|
终结点的专用 IP 地址。
|
|
protocol
|
string
|
终结点的协议。
|
createdByType
枚举
创建资源的标识的类型。
| 值 |
说明 |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DataDisksGroups
Object
角色的数据磁盘组。
| 名称 |
类型 |
说明 |
|
diskSizeGB
|
integer
(int32)
|
只读。 DiskSize(以 GB 为单位)。 不要设置此值。
|
|
disksPerNode
|
integer
(int32)
|
每个节点的磁盘数。
|
|
storageAccountType
|
string
|
只读。 存储帐户类型。 不要设置此值。
|
DaysOfWeek
枚举
基于计划的自动缩放规则的一周中的天数
| 值 |
说明 |
|
Monday
|
|
|
Tuesday
|
|
|
Wednesday
|
|
|
Thursday
|
|
|
Friday
|
|
|
Saturday
|
|
|
Sunday
|
|
DirectoryType
枚举
目录类型。
DiskEncryptionProperties
Object
磁盘加密属性
| 名称 |
类型 |
默认值 |
说明 |
|
encryptionAlgorithm
|
JsonWebKeyEncryptionAlgorithm
|
|
加密算法标识符,默认 RSA-OAEP。
|
|
encryptionAtHost
|
boolean
|
False
|
指示是否启用资源磁盘加密。
|
|
keyName
|
string
|
|
用于启用磁盘加密的密钥名称。
|
|
keyVersion
|
string
|
|
用于启用磁盘加密的特定密钥版本。
|
|
msiResourceId
|
string
|
|
用于访问密钥保管库的托管标识的资源 ID。
|
|
vaultUri
|
string
|
|
客户密钥所在的基密钥库 URI,例如。 https://myvault.vault.azure.net
|
EncryptionInTransitProperties
Object
传输中加密属性。
| 名称 |
类型 |
默认值 |
说明 |
|
isEncryptionInTransitEnabled
|
boolean
|
False
|
指示群集节点间通信是否在传输中加密。
|
ErrorResponse
Object
描述错误响应的格式。
| 名称 |
类型 |
说明 |
|
code
|
string
|
错误代码
|
|
message
|
string
|
指示作失败的原因的错误消息。
|
Errors
Object
与群集创建关联的错误消息。
| 名称 |
类型 |
说明 |
|
code
|
string
|
错误代码。
|
|
message
|
string
|
错误消息。
|
ExcludedServicesConfig
Object
创建群集时将排除服务的配置。
| 名称 |
类型 |
说明 |
|
excludedServicesConfigId
|
string
|
已排除服务的配置 ID。
|
|
excludedServicesList
|
string
|
排除的服务的列表。
|
HardwareProfile
Object
硬件配置文件。
| 名称 |
类型 |
说明 |
|
vmSize
|
string
|
VM 的大小
|
HDInsightClusterProvisioningState
枚举
预配状态,仅出现在响应中。
| 值 |
说明 |
|
InProgress
|
|
|
Failed
|
|
|
Succeeded
|
|
|
Canceled
|
|
|
Deleting
|
|
IPConfiguration
Object
专用链接服务的 IP 配置。
| 名称 |
类型 |
说明 |
|
id
|
string
|
专用链接 IP 配置 ID。
|
|
name
|
string
|
专用链接 IP 配置的名称。
|
|
properties.primary
|
boolean
|
指示此 IP 配置是否是相应 NIC 的主要配置。
|
|
properties.privateIPAddress
|
string
|
IP 地址。
|
|
properties.privateIPAllocationMethod
|
PrivateIPAllocationMethod
|
分配专用 IP 地址的方法。
|
|
properties.provisioningState
|
PrivateLinkConfigurationProvisioningState
|
专用链接配置预配状态,该状态仅在响应中显示。
|
|
properties.subnet
|
ResourceId
|
子网资源 ID。
|
|
type
|
string
|
专用链接 IP 配置的类型。
|
JsonWebKeyEncryptionAlgorithm
枚举
加密算法标识符,默认 RSA-OAEP。
| 值 |
说明 |
|
RSA-OAEP
|
|
|
RSA-OAEP-256
|
|
|
RSA1_5
|
|
KafkaRestProperties
Object
包含 AAD 安全组信息的 kafka rest 代理配置。
| 名称 |
类型 |
说明 |
|
clientGroupInfo
|
ClientGroupInfo
|
AAD 安全组的信息。
|
|
configurationOverride
|
object
|
需要重写的配置。
|
LinuxOperatingSystemProfile
Object
ssh 用户名、密码和 ssh 公钥。
| 名称 |
类型 |
说明 |
|
password
|
string
|
密码。
|
|
sshProfile
|
SshProfile
|
SSH 配置文件。
|
|
username
|
string
|
用户名。
|
NetworkProperties
Object
网络属性。
OsProfile
Object
Linux作系统配置文件。
OSType
枚举
操作系统的类型。
PrivateEndpoint
Object
专用终结点。
| 名称 |
类型 |
说明 |
|
id
|
string
|
专用终结点 ID。
|
PrivateEndpointConnection
Object
专用终结点连接。
| 名称 |
类型 |
说明 |
|
id
|
string
|
资源的完全限定资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
name
|
string
|
资源的名称
|
|
properties.linkIdentifier
|
string
|
链接标识符。
|
|
properties.privateEndpoint
|
PrivateEndpoint
|
专用终结点连接的专用终结点
|
|
properties.privateLinkServiceConnectionState
|
PrivateLinkServiceConnectionState
|
专用链接服务连接状态。
|
|
properties.provisioningState
|
PrivateEndpointConnectionProvisioningState
|
预配状态,仅出现在响应中。
|
|
systemData
|
systemData
|
与创建和上次修改资源相关的元数据。
|
|
type
|
string
|
资源的类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
PrivateEndpointConnectionProvisioningState
枚举
预配状态,仅出现在响应中。
| 值 |
说明 |
|
InProgress
|
|
|
Updating
|
|
|
Failed
|
|
|
Succeeded
|
|
|
Canceled
|
|
|
Deleting
|
|
PrivateIPAllocationMethod
枚举
分配专用 IP 地址的方法。
PrivateLink
枚举
指示是否启用专用链接。
PrivateLinkConfiguration
Object
专用链接配置。
| 名称 |
类型 |
说明 |
|
id
|
string
|
专用链接配置 ID。
|
|
name
|
string
|
专用链接配置的名称。
|
|
properties.groupId
|
string
|
要向其应用专用链接配置的 HDInsight 专用可链接子资源名称。 例如,“headnode”、“gateway”、“edgenode”。
|
|
properties.ipConfigurations
|
IPConfiguration[]
|
专用链接服务的 IP 配置。
|
|
properties.provisioningState
|
PrivateLinkConfigurationProvisioningState
|
专用链接配置预配状态,该状态仅在响应中显示。
|
|
type
|
string
|
专用链接配置的类型。
|
PrivateLinkConfigurationProvisioningState
枚举
专用链接配置预配状态,该状态仅在响应中显示。
| 值 |
说明 |
|
InProgress
|
|
|
Failed
|
|
|
Succeeded
|
|
|
Canceled
|
|
|
Deleting
|
|
PrivateLinkServiceConnectionState
Object
专用链接服务连接状态。
PrivateLinkServiceConnectionStatus
枚举
具体的专用链接服务连接。
| 值 |
说明 |
|
Approved
|
|
|
Rejected
|
|
|
Pending
|
|
|
Removed
|
|
QuotaInfo
Object
群集的配额属性。
| 名称 |
类型 |
说明 |
|
coresUsed
|
integer
(int32)
|
群集使用的核心。
|
ResourceId
Object
Azure 资源 ID。
| 名称 |
类型 |
说明 |
|
id
|
string
|
Azure 资源 ID。
|
ResourceIdentityType
枚举
用于群集的标识类型。 类型“SystemAssigned,UserAssigned”包括隐式创建的标识和一组用户分配的标识。
| 值 |
说明 |
|
SystemAssigned
|
|
|
UserAssigned
|
|
|
SystemAssigned, UserAssigned
|
|
|
None
|
|
ResourceProviderConnection
枚举
资源提供程序连接的方向。
Role
Object
描述群集上的角色。
| 名称 |
类型 |
默认值 |
说明 |
|
VMGroupName
|
string
|
|
虚拟机组的名称。
|
|
autoscale
|
Autoscale
|
|
自动缩放配置。
|
|
dataDisksGroups
|
DataDisksGroups[]
|
|
角色的数据磁盘组。
|
|
encryptDataDisks
|
boolean
|
False
|
指示是否加密数据磁盘。
|
|
hardwareProfile
|
HardwareProfile
|
|
硬件配置文件。
|
|
minInstanceCount
|
integer
(int32)
|
|
群集的最小实例计数。
|
|
name
|
string
|
|
角色的名称。
|
|
osProfile
|
OsProfile
|
|
操作系统配置文件。
|
|
scriptActions
|
ScriptAction[]
|
|
角色上的脚本操作列表。
|
|
targetInstanceCount
|
integer
(int32)
|
|
群集的实例计数。
|
|
virtualNetworkProfile
|
VirtualNetworkProfile
|
|
虚拟网络配置文件。
|
ScriptAction
Object
描述群集上角色的脚本作。
| 名称 |
类型 |
说明 |
|
name
|
string
|
脚本操作的名称。
|
|
parameters
|
string
|
提供的脚本的参数。
|
|
uri
|
string
|
脚本的 URI。
|
SecurityProfile
Object
包含 HDInsight 群集的 SSH 公钥的安全配置文件。
| 名称 |
类型 |
说明 |
|
aaddsResourceId
|
string
|
用户的 Azure Active Directory 域服务的资源 ID。
|
|
clusterUsersGroupDNs
|
string[]
|
可选。 群集用户组的可分辨名称
|
|
directoryType
|
DirectoryType
|
目录类型。
|
|
domain
|
string
|
组织的 Active Directory 域。
|
|
domainUserPassword
|
string
(password)
|
域管理员密码。
|
|
domainUsername
|
string
|
将在群集上具有管理员权限的域用户帐户。
|
|
ldapsUrls
|
string[]
|
要与 Active Directory 通信的 LDAPS 协议 URL。
|
|
msiResourceId
|
string
|
用户分配的标识有权在用户的 AADDS 中读取和创建与群集相关的项目。
|
|
organizationalUnitDN
|
string
|
Active Directory 中的组织单位,用于放置群集和服务帐户。
|
SshProfile
Object
SSH 公钥的列表。
SshPublicKey
Object
群集节点的 SSH 公钥。
| 名称 |
类型 |
说明 |
|
certificateData
|
string
|
SSH 的证书。
|
StorageAccount
Object
存储帐户。
| 名称 |
类型 |
说明 |
|
container
|
string
|
存储帐户中的容器,仅用于为 WASB 存储帐户指定。
|
|
fileSystem
|
string
|
文件系统,仅用于为 Azure Data Lake Storage Gen 2 指定。
|
|
fileshare
|
string
|
文件共享名称。
|
|
isDefault
|
boolean
|
存储帐户是否为默认存储帐户。
|
|
key
|
string
|
存储帐户访问密钥。
|
|
msiResourceId
|
string
|
只能为 Azure Data Lake Storage Gen 2 指定允许访问存储帐户的托管标识(MSI)。
|
|
name
|
string
|
存储帐户的名称。
|
|
resourceId
|
string
|
存储帐户的资源 ID,仅用于为 Azure Data Lake Storage Gen 2 指定。
|
|
saskey
|
string
|
共享访问签名密钥。
|
StorageProfile
Object
存储配置文件。
systemData
Object
与创建和上次修改资源相关的元数据。
| 名称 |
类型 |
说明 |
|
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
|
createdBy
|
string
|
创建资源的标识。
|
|
createdByType
|
createdByType
|
创建资源的标识的类型。
|
|
lastModifiedAt
|
string
(date-time)
|
上次修改的资源时间戳(UTC)
|
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|
Tier
枚举
群集层。
UserAssignedIdentity
Object
用户分配的标识
| 名称 |
类型 |
说明 |
|
clientId
|
string
|
用户分配标识的客户端 ID。
|
|
principalId
|
string
|
用户分配标识的主体 ID。
|
|
tenantId
|
string
|
用户分配标识的租户 ID。
|
VirtualNetworkProfile
Object
虚拟网络属性。
| 名称 |
类型 |
说明 |
|
id
|
string
|
虚拟网络的 ID。
|
|
subnet
|
string
|
子网的名称。
|