如何以编程方式在azure云服务中设置输入端点?

时间:2015-04-08 10:21:54

标签: java azure sdk

我正在使用java sdk在2个虚拟机上创建云服务。服务创建成功并且还在运行但是当我检查新创建的云服务的输入端点时,它说'#34;没有找到端点"。但我正在创建虚拟机时设置端点详细信息。这是代码段。

ArrayList<InputEndpoint> endPointList = new ArrayList<InputEndpoint>();

InputEndpoint endPoint = new InputEndpoint();

endPoint.setName("ssh");

endPoint.setPort(22);

endPoint.setLocalPort(22);

endPoint.setProtocol("tcp");

endPointList.add(endPoint);


configurationSetList = new ArrayList<ConfigurationSet>();

configurationSet = new ConfigurationSet();


configurationSet.setConfigurationSetType(ConfigurationSetTypes.LINUXPROVISIONINGCONFIGURATION);

configurationSet.setComputerName(roleName);

configurationSet.setUserName(userName);

configurationSet.setUserPassword(pswd);
                        configurationSet.setAdminPassword(adminUserPassword);

configurationSet.setAdminUserName(adminUserName);

configurationSet.setEnableAutomaticUpdates(false);

configurationSet.setHostName(clusterName + ".cloudapp.net");

configurationSet.setInputEndpoints(endPointList);

configurationSetList.add(configurationSet);


ArrayList<Role> roleList = new ArrayList<Role>();

Role role = new Role();

role.setRoleName(roleName);

role.setRoleType(VirtualMachineRoleType.PersistentVMRole.toString());

role.setRoleSize(VirtualMachineRoleSize.SMALL);

role.setProvisionGuestAgent(true);

role.setConfigurationSets(configurationSetList);

role.setOSVirtualHardDisk(oSVirtualHardDisk);

roleList.add(role);

如果我做错了,请告诉我。

1 个答案:

答案 0 :(得分:0)

您需要创建其他ConfigurationSet,

ConfigurationSet configurationSetForNetwork = new ConfigurationSet(); 

configurationSetForNetwork.setConfigurationSetType(ConfigurationSetTypes.NETWORKCONFIGURATION);
configurationSetList.add(configurationSetForNetwork);
configurationSetList.add(otherConfigurationSet...);
...
configurationSetForNetwork.setInputEndpoints(endPointList);
//If you need the one public ip
PublicIP publicIP = new PublicIP();
publicIP.setName(vitualNetworkName);//VNET Name
ArrayList publicIPS = new ArrayList();
publicIPS.add(publicIP);
configurationSetForNetwork.setPublicIPs(publicIPS);
相关问题