I am trying to connect to Azure Service Bus from my webjob using Managed Identities. But unfortunately, I am getting the following error
com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "10/10/2020 6:50:38 AM +00:00"
I have enabled Identity and assigned Contributor role for connecting to Service bus. Also, in the code, I have used ClientSettings to create a connection with Service bus.
ClientFactory.createMessageReceiverFromEntityPathAsync(namespace, queueName,new ClientSettings(TokenProvider.createManagedServiceIdentityTokenProvider()), ReceiveMode.RECEIVEANDDELETE).get();
Any idea how to resolve this exception, as it is thrown from built-in class ManagedServiceIdentityTokenProvider. Any help would be really helpful.
Thanks in advance.
EDIT -
I updated the service bus package to 3.2.0. Now I can't see NumberFormatException but I am getting java.lang.RuntimeException: java.net.SocketException: Permission denied: connect
even though I have provided the 'Owner' role to the webjob.
If you want to connect Azure Service bus with Azure Managed Identity, we need to assign some special role(Azure Service Bus Data Owner, Azure Service Bus Data Sender and Azure Service Bus Data Receiver ) to the MSI. For more details, please refer to here.
For example
Assing role to the MSI
Code