Authenticating Azure SDK for API management resource with free subscription

117 Views Asked by At

Authenticating Azure SDK for API management resource with free subscription results in error as below, Error Message Exception in thread "main" com.azure.identity.CredentialUnavailableException: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/java/identity/environmentcredential/troubleshoot WorkloadIdentityCredential authentication unavailable. The workload options are not fully configured. See the troubleshooting guide for more information. https://aka.ms/azsdk/java/identity/workloadidentitycredential/troubleshoot Managed Identity authentication is not available. SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache. AADSTS50078: Presented multi-factor authentication has expired due to policies configured by your administrator, you must refresh your multi-factor authentication to access '7************************3'. Trace ID: 9***************0 Correlation ID: 1da6d944-70b5-4c66-a271-b702acf019cf Timestamp: 2023-11-13 14:00:08Z AzureCliCredential authentication unavailable. Azure CLI not installed.To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/java/identity/azclicredential/troubleshoot Azure PowerShell authentication failed using defaultpowershell(pwsh) with following error: Unable to execute PowerShell. Please make sure that it is installed in your system. Azure PowerShell authentication failed using powershell-core(powershell) with following error: Az.Account module with version >= 2.2.0 is not installed. It needs to be installed to use Azure PowerShell Credential. AzureDeveloperCliCredential authentication unavailable. Azure Developer CLI not installed.To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/java/identity/azdevclicredential/troubleshootTo mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azure-identity-java-default-azure-credential-troubleshoot at com.azure.identity.ChainedTokenCredential.lambda$getToken$3(ChainedTokenCredential.java:107) at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:45) at reactor.core.publisher.Mono.subscribe(Mono.java:4490) at ... 63 more Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:100) at reactor.core.publisher.Mono.block(Mono.java:1742) at com.azure.resourcemanager.apimanagement.implementation.ApisClientImpl.getWithResponse(ApisClientImpl.java:828) at com.azure.resourcemanager.apimanagement.implementation.ApisClientImpl.get(ApisClientImpl.java:845) at com.azure.resourcemanager.apimanagement.implementation.ApisImpl.get(ApisImpl.java:79) at org.example.Main.main(Main.java:41)

Attaching my build.gradle and authentication code for reference...

AzureProfile profile = new AzureProfile("d****************6",
            "0************3", AzureEnvironment.AZURE);
    TokenCredential credential = new DefaultAzureCredentialBuilder()
            .tenantId("d******************6")
            .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
            .build();
    ApiManagementManager manager = ApiManagementManager
           .authenticate(credential, profile);
    System.out.println(manager.apis().get("apigee","adhigw","echo-api").description());


implementation ('com.azure.resourcemanager:azure-resourcemanager-resources:2.32.0')
implementation ('com.azure.resourcemanager:azure-resourcemanager:2.32.0')
implementation ('com.azure.resourcemanager:azure-resourcemanager-authorization:2.32.0')
implementation ('com.azure:azure-core-http-netty:1.13.9')
implementation ('com.azure.resourcemanager:azure-resourcemanager-mediaservices:2.3.0')

implementation ('com.azure.resourcemanager:azure-resourcemanager-apimanagement:1.0.0-beta.4')
implementation("com.azure:azure-core:1.39.0")
implementation("com.azure:azure-security-keyvault-secrets:4.6.1")
implementation("com.azure:azure-identity:1.10.4")
implementation("com.azure:azure-core-management:1.11.1")
implementation("com.azure.resourcemanager:azure-resourcemanager-apimanagement:1.0.0-beta.3")
implementation("com.azure.resourcemanager:azure-resourcemanager-authorization:2.26.0")
implementation("com.azure:azure-identity-providers-core:1.0.0-beta.1")
implementation("com.azure:azure-identity-extensions:1.1.3")
0

There are 0 best solutions below