azure free trial account not able to authenticate via java sdk

前端 未结 1 1846
忘掉有多难
忘掉有多难 2021-01-16 18:59

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 fo

1条回答
  •  再見小時候
    2021-01-16 19:44

    The issues are not related to free trial, refer to the first faq of https://azure.microsoft.com/en-us/pricing/free-trial-faq/.

    For the limits of Azure Subscription, please refer to https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits/.

    Seems that you can’t use management certificate to manage Azure Services successfully after uploaded management certificate in the settings of Azure Portal.

    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 = "";
            String keyStoreLocation = "";
            String keyStorePassword = "";
    
            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
    

    The code dependents on some maven repositories below in the pom.xml what you need to add in your project.

    
        com.microsoft.azure
        azure-svc-mgmt
        0.8.3
    
    
        com.microsoft.azure
        azure-svc-mgmt-compute
        0.8.3
    
    
        com.microsoft.azure
        azure-svc-mgmt-network
        0.8.3
    
    

    For the error of Azure CLI, I think you missed some necessary steps as below.

    Firstly, using command login and Azure username & password to connect your Azure subscription.

    $ azure login -u 
    

    Secondly, switching the Azure Service Management Mode for export certificate.

    $ azure config mode asm
    

    Lastly, downloading certiticate.

    $ azure account cert export
    

    Then, you can find the cert file called .pem at the current path.

    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.

    0 讨论(0)
提交回复
热议问题