MissingSubscriptionRegistration:订阅未注册为使用命名空间 'Microsoft.Storage'

MissingSubscriptionRegistration: The subscription is not registered to use namespace 'Microsoft.Storage'

尝试从 Azure-Java-SDK

运行CreateVMExample.java
   VirtualMachine vm = ComputeHelper.createVM(
                        resourceManagementClient, computeManagementClient, networkResourceProviderClient, storageManagementClient,
                        context, "javaSampleVM", "Foo12", "BaR@123rgababaab")
                        .getVirtualMachine();

                System.out.println(vm.getName() + " is created");

并出现以下错误。

Exception in thread "main" java.util.concurrent.ExecutionException: com.microsoft.windowsazure.exception.ServiceException: MissingSubscriptionRegistration: The subscription is not registered to use namespace 'Microsoft.Storage'.
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at com.microsoft.azure.management.storage.StorageAccountOperationsImpl.create(StorageAccountOperationsImpl.java:737)
    at com.microsoft.azure.utility.StorageHelper.createStorageAccount(StorageHelper.java:71)
    at com.microsoft.azure.utility.StorageHelper.createStorageAccount(StorageHelper.java:53)
    at com.microsoft.azure.utility.ComputeHelper.createVM(ComputeHelper.java:246)
    at com.microsoft.azure.utility.ComputeHelper.createVM(ComputeHelper.java:213)
    at com.microsoft.azure.auth.CreateVMExample.main(CreateVMExample.java:74)

由于我是 AWS 的 Azure 新手,不知道从哪里开始。看到与 Azure PS 相关的同类错误。但帮助不大。请提出一些建议。我正在使用 Azure Active Directory 身份验证。谢谢

您引用的存储帐户名称是否可能是旧存储帐户?如果您转到 portal.azure.com,存储帐户将分为两类:存储帐户(经典)和存储帐户。如果您引用的帐户在经典列表中,请尝试创建一个新的存储帐户然后引用它?

此问题是由使用 Azure AD 进行身份验证引起的。 文档 "Authenticating Azure Resource Management request"( https://msdn.microsoft.com/en-us/library/azure/dn790557.aspx) 说 "All of the tasks that you do on resources using the Azure Resource Manager must be authenticated with Azure Active Directory. "。所以使用ClassComputeHelper的Azure资源管理API必须通过AAD认证。

您需要先使用管理门户在 Azure AD 上设置身份验证。详细步骤请参考https://msdn.microsoft.com/en-us/library/azure/dn790557.aspx#bk_portal and https://azure.microsoft.com/en-us/documentation/articles/resource-group-create-service-principal-portal/.

Java中有一个调用 Azure AD 的示例项目 (https://github.com/Azure-Samples/active-directory-java-graphapi-web),它可以帮助您。