# Connect to AZURE SQL PAAS DB is getting failed

**URL:** <https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033>\
**Category:** Logstash\
**Created:** [July 12, 2024, 12:50pm UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033 "2024-07-12T12:50:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishna58](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@krishna58](https://discuss.elastic.co/u/krishna58)\
**Post date:** [July 12, 2024, 12:50pm UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/1 "2024-07-12T12:50:16Z")

</div>

Hi I am using the below script to connect to AZURE SQL PAAS DB from the logstash script. Service principal is created and added the RBAC role for both Service principal and SQL PAAS sever as a reader role. Please help on this

#file:  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:sqlserver://.database.windows.net:1433;database=workfusion;authentication=ActiveDirectoryPassword;driver=com.microsoft.sqlserver.jdbc.SQLServerDriver;clientid=_ **;tenantid=** __ **;clientsecret=** _**"  
jdbc\_user =\> ""  
jdbc\_password =\> ""  
jdbc\_driver\_library =\> "C:/Softwares/logstash-8.14.2/logstash-core/lib/jars/sqljdbc4-4.0.jar"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
statement\_filepath =\> "C:/Softwares/scriptscog/apac/uat/**.sql"  
tracking\_column =\> "epochtimestamp"  
use\_column\_value =\> true  
tracking\_column\_type =\> "numeric"  
schedule =\> "\* \* \* \* \*"  
}  
}

filter {  
mutate {  
remove\_field =\> ["epochtimestamp"]  
}  
}

output {  
# stdout {codec =\> json\_lines }  
kafka {  
codec =\> json  
topic\_id =\> ""  
bootstrap\_servers =\> ""  
message\_key =\> ""  
security\_protocol =\> ""  
ssl\_truststore\_location =\> "C:/Softwares/scriptscog/cert/aip-kafka-ts.jks"  
ssl\_truststore\_password =\> "\***"  
ssl\_keystore\_location =\> "C:/Softwares/scriptscog/cert/ipa-dashboard.jks"  
ssl\_keystore\_password =\> "**"

```
    }

```

}

But i am getting the below error.

```
    at org.jruby.RubyProc.call(org/jruby/RubyProc.java:354) ~[jruby.jar:?]
    at java.lang.Thread.run(java/lang/Thread.java:840) [?:?]

```

[2024-07-12T18:10:47,868][ERROR][logstash.inputs.jdbc][main] Unable to connect to database. Tried 1 times {:message  
=\>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: Login failed for user ''. ClientConnectionId:92b7c2c0-6a71-4ab4-  
90a2-887091fc4df9", :exception=\>Sequel::DatabaseConnectionError, :cause=\>#\<Java::ComMicrosoftSqlserverJdbc::SQLServerExc  
eption: Login failed for user ''. ClientConnectionId:92b7c2c0-6a71-4ab4-90a2-887091fc4df9\>, :backtrace=\>["com.microsoft.  
sqlserver.jdbc.SQLServerException.makeFromDatabaseError(com/microsoft/sqlserver/jdbc/SQLServerException.java:216)", "com  
.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(com/microsoft/sqlserver/jdbc/tdsparser.java:254)", "com.microsoft.sqlser  
ver.jdbc.TDSParser.parse(com/microsoft/sqlserver/jdbc/tdsparser.java:84)", "com.microsoft.sqlserver.jdbc.SQLServerConnec  
tion.sendLogon(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:2908)", "com.microsoft.sqlserver.jdbc.SQLServerConn  
ection.logon(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:2234)", "com.microsoft.sqlserver.jdbc.SQLServerConnec  
tion.access$000(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:41)", "com.microsoft.sqlserver.jdbc.SQLServerConne  
ction$LogonCommand.doExecute(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:2220)", "com.microsoft.sqlserver.jdbc  
.TDSCommand.execute(com/microsoft/sqlserver/jdbc/IOBuffer.java:5696)", "com.microsoft.sqlserver.jdbc.SQLServerConnection  
.executeCommand(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:1715)", "com.microsoft.sqlserver.jdbc.SQLServerCon  
nection.connectHelper(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:1326)", "com.microsoft.sqlserver.jdbc.SQLSer  
verConnection.login(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:991)", "com.microsoft.sqlserver.jdbc.SQLServer  
Connection.connect(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:827)", "com.microsoft.sqlserver.jdbc.SQLServerD  
river.connect(com/microsoft/sqlserver/jdbc/SQLServerDriver.java:1012)", "jdk.internal.reflect.NativeMethodAccessorImpl.i  
nvoke0(Native Method)", "jdk.internal.reflect.NativeMethodAccessorImpl.invoke(jdk/internal/reflect/NativeMethodAccessorI  
mpl.java:77)", "jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(jdk/internal/reflect/DelegatingMethodAccessorIm  
pl.java:43)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:568)", "org.jruby.javasupport.JavaMethod.in  
vokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:330)", "org.jruby.javasupport.JavaMethod.invokeDir  
ect(org/jruby/javasupport/JavaMethod.java:188)", "RUBY.connect(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/ge  
ms/sequel-5.80.0/lib/sequel/adapters/jdbc.rb:237)", "RUBY.new\_connection(C:/Softwares/logstash-8.14.2/vendor/bundle/jrub  
y/3.1.0/gems/sequel-5.80.0/lib/sequel/database/connecting.rb:248)", "RUBY.make\_new(C:/Softwares/logstash-8.14.2/vendor/b  
undle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/connection\_pool.rb:163)", "RUBY.assign\_connection(C:/Softwares/logstash-  
8.14.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/connection\_pool/threaded.rb:209)", "RUBY.acquire(C:/Softw  
ares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/connection\_pool/threaded.rb:139)", "RUBY.ho  
ld(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/connection\_pool/threaded.rb:91)"  
, "RUBY.synchronize(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/database/connec  
ting.rb:293)", "RUBY.test\_connection(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/seque  
l/database/connecting.rb:302)", "RUBY.initialize(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80  
.0/lib/sequel/database/misc.rb:189)", "org.jruby.RubyClass.new(org/jruby/RubyClass.java:922)", "org.jruby.RubyClass$INVO  
KER$i$newInstance.call(org/jruby/RubyClass$INVOKER$i$newInstance.gen)", "RUBY.connect(C:/Softwares/logstash-8.14.2/vendo  
r/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/database/connecting.rb:57)", "RUBY.connect(C:/Softwares/logstash-8.14  
.2/vendor/bundle/jruby/3.1.0/gems/sequel-5.80.0/lib/sequel/core.rb:124)", "RUBY.jdbc\_connect(C:/Softwares/logstash-8.14.  
2/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.11/lib/logstash/plugin\_mixins/jdbc/jdbc.rb:123)", "org.jr  
uby.RubyKernel.loop(org/jruby/RubyKernel.java:1722)", "org.jruby.RubyKernel$INVOKER$s$0$0$loop.call(org/jruby/RubyKernel  
$INVOKER$s$0$0$loop.gen)", "RUBY.jdbc\_connect(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/logstash-integ  
ration-jdbc-5.4.11/lib/logstash/plugin\_mixins/jdbc/jdbc.rb:120)", "RUBY.open\_jdbc\_connection(C:/Softwares/logstash-8.14.  
2/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.11/lib/logstash/plugin\_mixins/jdbc/jdbc.rb:163)", "RUBY.r  
egister(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/logstash-integration-jdbc-5.4.11/lib/logstash/inputs  
/jdbc.rb:309)", "RUBY.register(C:/Softwares/logstash-8.14.2/vendor/bundle/jruby/3.1.0/gems/logstash-mixin-ecs\_compatibil  
ity\_support-1.3.0-java/lib/logstash/plugin\_mixins/ecs\_compatibility\_support/target\_check.rb:48)", "RUBY.register\_plugins  
(C:/Softwares/logstash-8.14.2/logstash-core/lib/logstash/java\_pipeline.rb:237)", "org.jruby.RubyArray.each(org/jruby/Rub  
yArray.java:1981)", "org.jruby.RubyArray$INVOKER$i$0$0$each.call(org/jruby/RubyArray$INVOKER$i$0$0$each.gen)", "RUBY.reg  
ister\_plugins(C:/Softwares/logstash-8.14.2/logstash-core/lib/logstash/java\_pipeline.rb:236)", "RUBY.start\_inputs(C:/Soft  
wares/logstash-8.14.2/logstash-core/lib/logstash/java\_pipeline.rb:395)", "RUBY.start\_workers(C:/Softwares/logstash-8.14.  
2/logstash-core/lib/logstash/java\_pipeline.rb:320)", "RUBY.run(C:/Softwares/logstash-8.14.2/logstash-core/lib/logstash/j  
ava\_pipeline.rb:194)", "RUBY.start(C:/Softwares/logstash-8.14.2/logstash-core/lib/logstash/java\_pipeline.rb:146)", "org.  
jruby.RubyProc.call(org/jruby/RubyProc.java:354)", "java.lang.Thread.run(java/lang/Thread.java:840)"]}

---

<div class="post-metadata">

**Author:** ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)\
**Post date:** [July 14, 2024, 8:27am UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/2 "2024-07-14T08:27:50Z")

</div>

Hi @krishna58 , welcome to our community.

The credentials such as the client ID, tenant ID, and client secret in your configuration should have the values, shouldn't they?

---

<div class="post-metadata">

**Author:** ![krishna58](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@krishna58](https://discuss.elastic.co/u/krishna58)\
**Post date:** [July 15, 2024, 1:02pm UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/3 "2024-07-15T13:02:06Z")

</div>

Hi @Alex_Salgado-Elastic

Yes they are correct and i am able to login manually in SSMS.

Would you suggest any changes to the script?

---

<div class="post-metadata">

**Author:** ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)\
**Post date:** [July 15, 2024, 1:15pm UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/4 "2024-07-15T13:15:08Z")

</div>

Hi @krishna58 ,  
Please fill in the credential values in the input section of your Logstash configuration. It seems like they are empty, or did you just remove them before sharing it on the forum?

```auto

jdbc {
  jdbc_connection_string => "jdbc:sqlserver://.database.windows.net:1433;database=workfusion;authentication=ActiveDirectoryPassword;driver=com.microsoft.sqlserver.jdbc.SQLServerDriver;clientid=<YOUR_clientid>;tenantid=<YOUR_tenantid>;clientsecret=<YOUR_clientsecret>"
  jdbc_user => "<YOUR_USERNAME_HERE>" # Replace with your actual username
  jdbc_password => "<YOUR_PASSWORD_HERE>" # Replace with your actual password
  jdbc_driver_library => "C:/Softwares/logstash-8.14.2/logstash-core/lib/jars/sqljdbc4-4.0.jar"
  jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  statement_filepath => "C:/Softwares/scriptscog/apac/uat/.sql"
  tracking_column => "epochtimestamp"
  use_column_value => true
  tracking_column_type => "numeric"
  schedule => "* * * * *"
}

```

---

<div class="post-metadata">

**Author:** ![krishna58](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@krishna58](https://discuss.elastic.co/u/krishna58)\
**Post date:** [July 15, 2024, 1:33pm UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/5 "2024-07-15T13:33:49Z")

</div>

Hi @Alex_Salgado-Elastic

I have removed those before sharing on the forum.

---

<div class="post-metadata">

**Author:** ![krishna58](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@krishna58](https://discuss.elastic.co/u/krishna58)\
**Post date:** [July 16, 2024, 10:07am UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/7 "2024-07-16T10:07:34Z")

</div>

Hi @Alex_Salgado-Elastic

Can you please help to resolve this issues?

Thanks,  
Krishna

---

<div class="post-metadata">

**Author:** ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)\
**Post date:** [July 17, 2024, 12:10pm UTC](https://discuss.elastic.co/t/connect-to-azure-sql-paas-db-is-getting-failed/363033/8 "2024-07-17T12:10:03Z")

</div>

Hello @krishna58

Please refrain from directing questions to just one individual; instead, address the community so that everyone can assist you.

Unless you prefer individual support, which you can hire according to your license, the community here strives voluntarily to help everyone asynchronously and according to their availability.

In my opinion, I still believe there might be an issue with your connection. What I can suggest:

1. Check Azure SQL Database Settings:

2. Check JDBC Driver Dependencies:

3. Create simple connection tests and gradually add the details.

Sources that might help you:

- [Ingest data from a relational database into Elasticsearch Service | Elasticsearch Service Documentation | Elastic](https://www.elastic.co/guide/en/cloud/current/ec-getting-started-search-use-cases-db-logstash.html#ec-db-logstash-pipeline)
- [Jdbc input plugin | Logstash Reference [8.14] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html)
- [Logstash pipeline from SQL Server to Elastic Search | by Amin Mirzaee | Medium](https://medium.com/@amin.mirzaee/logstash-pipeline-from-sql-server-to-elastic-search-17c05a6b4a1e)
- [Elasticsearch to Azure Data Explorer: Migration guide - Azure Data Explorer | Microsoft Learn](https://learn.microsoft.com/en-us/azure/data-explorer/migrate-elasticsearch-to-azure-data-explorer)
