Azure Stream Analytics - User Verification - azure

I have data in an Event Hub which i'm passing to an Azure SQL Server database via a Stream Analytics job. I've had it working, but now when i start the job i get a 'Login failed for user xxx'.
I can log into the database and make changes etc using Azure Data Studio or via the Azure portal, but when i try to test the Output connection or run the job, it fails with the above error. The user exists and has admin access etc. Anyone seen this before ?
Thanks in advance
JC

This problem is generally caused by the firewall, so first check the firewall of your sql server.
enter image description here

Related

Azure SQL Database - randomly error: Login failed for user '***'

I get randomly from time to time error Login failed for user '***' when the application tries to connect with Azure SQL Database.
In most cases application has no problem with logging in to that user, unfortunately from time to time I get such an error. DB hasn't problems (at least I don't see any of them) isn't overloaded no alerts, only that problem that happens from time to time
Login failed for user ‘***’
The error occurs when the username or password or there’s something missing in the connection string. You can check the Azure SQL log-in logs in the Audit Logs section of your Azure SQL server and you can explicitly view #sys.event_log logs table to check the connectivity failures of your Azure SQL.
I created one console app and reproduced the same Login failed for user error where my db name in the connection string is wrong, Similar error might occur if you add an incorrect password or if a password change is not updated in your connection string Refer to below:-
You can enable Audit Logs for your Azure SQL DB like below to get more insights on the connection failure:-
Audit Logs are sent to Log analytics like below:-
Database Authentication logs :-
You can also auto-resolve the connection issue by visiting Diagnose and solve problems section of your Azure SQL DB where you can select your issue and Azure will run diagnostics queries/recommendation on your Azure SQL DB like below:-
For Connectivity -Connection Timeouts issues, Query is recommended like below:-
You can also query the connection failed logs directly in the SSMS like below:-
Select * From sys.event_log
Reference:-
sys.event_log (Azure SQL Database) - SQL Server | Microsoft Learn
Azure SQL Auditing for Azure SQL Database and Azure Synapse Analytics - Azure SQL Database | Microsoft Learn

while I am connecting the my java application to azure sql database, I have to run the application twice

while I am connecting the my java application to azure sql database, I have to run the application twice .
1: while running the application I am able to create the database. it takes the database from the tenent.properties:-
devTest=DbName
database.properties file:-
jdbc:sqlserver://XXXXXserver2.database.windows.net:1433;user=XXXX#XXXXserver2;password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
2: while running the application second time my connection ulr looks like below and I'm getting connected to the database which is mention in the connection string
tenant. properties:-
DevTest= DbName
database. properties file:-
jdbc:sqlserver://XXXXXserver2.database.windows.net:1433;database=DbName;user=XXXX#XXXXXserver2;password=your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
Please help me out.
Advance thank you!!!!!!!!!!!!!
One of the workaround you can follow to resolve the above,
So basically you are not getting any error while connecting the azure sql database to java using JDBC driver for sql server . The difference only we can see is the db name is added after running twice.
Similar issue we had faced and after checking our internet connectivity and restarting the system able to connect when executing for the first time itself ,Suggest you to please try the same restart the application and system.
Few of the things need to ensure that you have added the following to your src/main/resources/application.properties
url=jdbc:sqlserver://$AZ_DATABASE_NAME.database.windows.net:1433;database=demo;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
user=demo#$AZ_DATABASE_NAME
password=$AZ_SQL_SERVER_PASSWORD
The above provided information to be apply for the sql server which you have created earlier before creating the java project.
For complete setup please refer this MICROSOFT DOCUMENTATION| Use Java and JDBC with Azure SQL Database
For more information please refer this MICROSOFT DOCUMENTATION| How to connect to Azure SQL with JDBC

Logs for Azure Storage account SFTP service?

Can we get logs from the Azure SFTP service in Storage account? I've enabled the SFTP feature in the storage account which works as an SFTP service, I'm able to push files into it using client apps like Filezilla and Win SCP. But it's not working when I'm trying to push files from a client app. Client app is a reporting system which has the ability to push reports into an SFTP server.
My intention is to check the logs for the SFTP service and see why it's not serving requests from the client app
If the client can't reach the server for whatever reason, having logs on the Azure side won't help in any way. Check the client logs. What error are you getting?
Here's a list of common issues that might help:
https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-known-issues
As per this current documentation, you can pull the sftp logs by applying the filters in the activity logs or by enabling diagnostic settings on the storage accounts.
You can refer this documentation , for more information about the know issues with SFTP protocol in Azure blob storage account & currently this feature is in preview.
You can activate logs on your storage account from the diagnostic settings.
Go to the sftp storage account resource, then from the side menu you will see:
From it select the storage type (blob for example) you can then add a diagnostic settings:
Then select the category and select to which ever destination you desire, for example you can map it to a log analytic resource
Then you can query the logs, for example:
StorageBlobLogs
| where Category contains "StorageWrite"

How to get Users Logging Information Using Log Analytics in Azure SQL Database

I am trying to get Users logged in information in Azure SQL Database Using Log Analytics. Can it be possible if so, can you please help me on this ?
Below are Options available in Diagnostic Settings for Azure SQL Database.
Click 'Add Diagnostic setting' above to configure the collection of the following data:
DmsWorkers
ExecRequests
RequestSteps
SqlRequests
Waits
Basic
InstanceAndAppAdvanced
WorkloadManagement
I want to achieve this without using Sys schemas objects related to Azure SQL Databases.
Thanks,
Brahma
You need to enable Auditing in Azure SQL Server using and then you can check the logs in Azure Log Analytics.
Easiest way to enable auditing is through the Azure Portal. However, it can be easily set up through ARM templates, Azure Powershell, Azure CLI.
Auditing can be enabled either at the individual database level or at the logical server level. If enabled at the server level then it automatically applies to existing databases and any new databases that are created.
However, enabling both at the server and database level leads to duplicate logs.
In the homepage of the desired Azure Sql server, in the left pane there is an option for “Auditing”.
By default, Auditing is off. Enable it. Choose the Log Analytics Workspace where you need to store the logs. Click on Save.
Click on Add diagnostics setting. Let us enable diagnostics for errors and InstanceAndAppAdvanced. Send this data to the log analytics workspace using your subscription and log analytics workspace. Click on Save for the configuration.
To view the logs, open up the Log Analytics workspace that was configured as a sink and choose logs and select the scope.
Summarizing the connection attempts by caller IP addresses
AzureDiagnostics
|summarize count() by client_ip_s
Source: https://www.mssqltips.com/sqlservertip/6782/kusto-query-language-query-audit-data-azure-sql-database/

How to connect Azure Web App to Azure SQL Database?

I'm having what I hope is a simple problem.
I've published an API to an Azure Web App, which should fetch data from an Azure SQL database, but I'm getting a 500 error, which of course isn't helpful. Checking the logs in Azure doesn't give anything more useful to me.
I've added the connection string to the connection strings in the Web App. I have also created a method which returns the connection string from the repository class that's using it, so I know it's definitely seeing the correct connection string; so this means it's an issue connecting to the database with that connection string.
I have ensured that 'Allow access to Azure Services' is switched on, and when I use the query editor I can successfully pull data from the database.
I've also connected to the database using SQL management studio so I know the database can be reached.
What am I doing wrong?
As usual it turns out to be my stupidity, but I'll answer here in case it helps someone else...
I just updated my local app to use the Azure db connection string so I could get a more detailed error and it said the keyword was not supported 'initial catalog'.
This is when I realised that I developed this locally using Postgresql but couldn't justify the costs of that on Azure so switched to Sql Server but didn't change my connections to SqlConnection types!

Resources