How to connect a Quarkus Function app with Azure SQL DB using Managed Identity?

Copper Contributor

I am attempting to connect my Quarkus Function app to an Azure MS SQL database using managed identity.My question is whether it is possible to connect the function app to the SQL Server using Managed Identity. Whether Quarkus framework provide support for Azure Managed Identity when connecting to Azure SQL Server? I have been referring to the following document for configuring the managed identity: https://learn.microsoft.com/en-us/azure/azure-functions/functions-identity-access-azure-sql-with-man.... However, when I attempt to connect, I receive a timeout error.

 

 

Error message "Quarkus bootstrap failed. java.lang.RuntimeException: Failed to start quarkus at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source) at io.quarkus.runtime.Application.start(Application.java:101) at io.quarkus.azure.functions.resteasy.runtime.BaseFunction.initQuarkus(BaseFunction.java:57) at io.quarkus.azure.functions.resteasy.runtime.BaseFunction$QuarkusInitializer.(BaseFunction.java:191) at io.quarkus.azure.functions.resteasy.runtime.BaseFunction.ensureQuarkusInitialized(BaseFunction.java:46) at io.quarkus.azure.functions.resteasy.runtime.Function.run(Function.java:18) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:22) at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:22) at com.microsoft.azure.functions.worker.chain.FunctionExecutionMiddleware.invoke(FunctionExecutionMiddleware.java:19) at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21) at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:125) at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34) at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10) at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44) at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.lang.RuntimeException: javax.persistence.PersistenceException: [PersistenceUnit: ] Unable to build Hibernate SessionFactory at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:82) at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:95) at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy_0(Unknown Source) at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits1868654632.deploy(Unknown Source) ... 24 more Caused by: javax.persistence.PersistenceException: [PersistenceUnit: ] Unable to build Hibernate SessionFactory at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.persistenceException(FastBootEntityManagerFactoryBuilder.java:116) at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:76) at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:72) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:167) at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:68) ... 1 more Caused by: org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.(DdlTransactionIsolatorJtaImpl.java:62) at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:53) at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:205) at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:102) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:196) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:85) at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:335) at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:74) ... 6 more Caused by: java.sql.SQLException: Acquisition timeout while waiting for new connection at io.agroal.pool.ConnectionPool.handlerFromSharedCache(ConnectionPool.java:320) at io.agroal.pool.ConnectionPool.getConnection(ConnectionPool.java:248) at io.agroal.pool.DataSource.getConnection(DataSource.java:86) at io.quarkus.hibernate.orm.runtime.customized.QuarkusConnectionProvider.getConnection(QuarkusConnectionProvider.java:23) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:181) at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.(DdlTransactionIsolatorJtaImpl.java:59) ... 13 more Caused by: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204) at io.agroal.pool.ConnectionPool.handlerFromSharedCache(ConnectionPool.java:296) ... 18 more"

1 Reply
This issue was now closed as I was able to connect with the SQL server post creating a new function app.