蔚蓝的免费试用帐户无法通过Java SDK的验证 [英] azure free trial account not able to authenticate via java sdk
问题描述
我使用简单的Java SDK的code核实蔚蓝的基本连接。我已上载在蔚蓝的门户设置管理证书。但我得到了以下异常,每当我尝试验证:
I am using simple java sdk code to verify the azure basic connection. I have uploaded the management certificate in the settings in the azure portal. But I am getting the following exception whenever I try to authenticate :
异常线程maincom.microsoft.windowsazure.exception.ServiceException:ForbiddenError:服务器无法验证请求。验证证书是有效的,并与此订阅关联。
在com.microsoft.windowsazure.exception.ServiceException.createFromXml(ServiceException.java:206)
在com.microsoft.windowsazure.management.LocationOperationsImpl.list(LocationOperationsImpl.java:162)
在com.mycompany.testproj1.test1.main(test1.java:46)
Exception in thread "main" com.microsoft.windowsazure.exception.ServiceException: ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription. at com.microsoft.windowsazure.exception.ServiceException.createFromXml(ServiceException.java:206) at com.microsoft.windowsazure.management.LocationOperationsImpl.list(LocationOperationsImpl.java:162) at com.mycompany.testproj1.test1.main(test1.java:46)
当我尝试使用蔚蓝CLI下载证书
When i try to download the certificate using azure cli
$蔚蓝帐户导出证书
信息:执行命令帐户导出证书
错误:此订阅不使用管理证书
信息:错误信息已被记录到/Users/tt/.azure/azure.err
错误:帐户证书导出命令失败。
$ azure account cert export info: Executing command account cert export error: This subscription does not use a management certificate info: Error information has been recorded to /Users/tt/.azure/azure.err error: account cert export command failed
这是关系到我使用的免费试用的?
Is this related to my use of free trial ?
推荐答案
的问题是不相关的免费试用,指的 https://azure.microsoft.com/en-us/pricing/free-trial-faq/ 。
The issues are not related to free trial, refer to the first faq of https://azure.microsoft.com/en-us/pricing/free-trial-faq/.
有关Azure订阅的限制,请参考的https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits/.
For the limits of Azure Subscription, please refer to https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits/.
看来你无法使用管理证书的Azure门户的设置来管理Azure服务成功上传后管理证书。
Seems that you can’t use management certificate to manage Azure Services successfully after uploaded management certificate in the settings of Azure Portal.
有在Java部分样品的code用于验证的Azure服务管理。
There is the partial sample code in Java for authenticating Azure Service Management.
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.microsoft.windowsazure.Configuration;
import com.microsoft.windowsazure.core.utils.KeyStoreType;
import com.microsoft.windowsazure.management.configuration.ManagementConfiguration;
import com.microsoft.windowsazure.management.compute.ComputeManagementService;
import com.microsoft.windowsazure.management.compute.ComputeManagementClient;
import com.microsoft.windowsazure.management.network.NetworkManagementService;
import com.microsoft.windowsazure.management.network.NetworkManagementClient;
String uri = "https://management.core.windows.net/";
String subscriptionId = "<your subscription id>";
String keyStoreLocation = "<KeyStore.jks>";
String keyStorePassword = "<password for KeyStore>";
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
);
// For Compute Management
ComputeManagementClient computeManagementClient = ComputeManagementService.create(config);
//For Networing Management
NetworkManagementClient client = NetworkManagementService.create(config);
// Others like above
下面在pom.xml一些Maven仓库,你需要在你的项目中添加哪些code家属。
The code dependents on some maven repositories below in the pom.xml what you need to add in your project.
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-svc-mgmt</artifactId>
<version>0.8.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-svc-mgmt-compute</artifactId>
<version>0.8.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-svc-mgmt-network</artifactId>
<version>0.8.3</version>
</dependency>
有关天青CLI的错误,我想你错过了一些必要的步骤如下。
For the error of Azure CLI, I think you missed some necessary steps as below.
首先,用命令登录
和Azure的用户名和放大器;密码,连接您的Azure订阅。
Firstly, using command login
and Azure username & password to connect your Azure subscription.
$ azure login -u <username@hostname>
其次,切换的Azure服务管理模式的出口证书。
Secondly, switching the Azure Service Management Mode for export certificate.
$ azure config mode asm
最后,下载certiticate。
Lastly, downloading certiticate.
$ azure account cert export
然后,你可以找到名为证书文件&LT;认购-ID方式&gt;质子交换膜
在当前路径
有关详细信息,您可以参考 https://开头azure.microsoft.com/en-us/documentation/articles/xplat-cli-connect/ 。
For details, you can refer to https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-connect/.
这个线程的任何关注,请随时告诉我。
Any concern for this thread, please feel free to let me know.
这篇关于蔚蓝的免费试用帐户无法通过Java SDK的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!