Skip to content

[BUG] Can not use FIC in CosmosDB with scala #41976

Open

Description

Describe the bug
When I use the ManagedIdentity to get token for Federate Credential in scala, the below throw exception:
block()/blockFirst()/blockLast() are blocking, which is not supported in thread cosmos-parallel-1

The code snip is:

def initCosmosClient(): CosmosClient = {
    println(s"Getting CosmosClient")

    val managedIdentityCredential = new ManagedIdentityCredentialBuilder()
    .clientId(miClientId)
    .build()

      val clientAssertionCredential = new ClientAssertionCredentialBuilder()
    .tenantId(tenantId)
    .clientId(appId)
    .clientAssertion(() => {
      try {
        val token = managedIdentityCredential.getTokenSync(new TokenRequestContext().addScopes("api://AzureADTokenExchange/.default"))
        if (token != null){
        token.getToken
    } else {
      ""
    }
    } catch {
      case e: Exception => {
      println(s"Getting CosmosClient with Exception ${e.getMessage}")

      ""
    }
    }
    })
    .additionallyAllowedTenants("*")
    .build()

      new CosmosClientBuilder()
    .endpoint(configs.host)
    .credential(clientAssertionCredential)
    .buildClient()
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions