由于answer检索VirtualMachines的PublicIPAddress是找不到网页,我试图用下面的代码天青从Azure中的Java SDK
Configuration config = ManagementConfiguration.configure(
new URI(uri),
subscriptionId,
keyStoreLocation, // the file path to the JKS
keyStorePassword, // the password for the JKS
KeyStoreType.jks // flags that I'm using a JKS keystore
);
NetworkResourceProviderClient networkResourceProviderClient = NetworkResourceProviderService.create(config);
PublicIpAddressListResponse PublicIpAddressListResponse =networkResourceProviderClient.getPublicIpAddressesOperations().listAll();
ArrayList<PublicIpAddress> PublicIpAddressList =PublicIpAddressListResponse.getPublicIpAddresses();
System.out.println(PublicIpAddressList.size());
使用Azure的AD ServicePrincipal认证,它返回检索的公网IP的大小 - 0
使用证书认证与“https://management.azure.com/” API,它返回 - AuthenticationFailed:
Exception in thread "main" com.microsoft.windowsazure.exception.ServiceException: AuthenticationFailed: Authentication failed. The 'Authorization' header is not present or provided in an invalid format.
at com.microsoft.windowsazure.exception.ServiceException.createFromJson(ServiceException.java:290)
at com.microsoft.azure.management.network.PublicIpAddressOperationsImpl.listAll(PublicIpAddressOperationsImpl.java:1443)
at com.microsoft.azure.auth.Program.main(Program.java:50)
任何想法如何检索所有虚拟机的公共IP地址?或者如何对其进行身份验证以获取IP值?