Data Factory - Cannot connect to SQL Database only when triggered from Blob - azure-sql-database

Also on the Microsoft Docs site here
I have a data factory pipeline that should use a Copy Data activity to insert rows from a CSV file of a blob into Azure Sql.
If I run the pipeline by clicking the "Debug" button in the designer window then it all works great. However, if I trigger the pipeline by copying the sample CSV to the blob container then I get the following error:
ErrorCode=SqlFailedToConnect,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot
connect to SQL Database: '', Database: '', User: ''. Check the linked
service configuration is correct, and make sure the SQL Database
firewall allows the integration runtime to access
I have checked that the target sql server database has the option checked to "Allow Azure services and resources to access this server".
Any ideas gratefully received!

Problem was I was missing a connection string value from the "Override template parameters" section of the release pipeline.
This meant that after deployment, the linked service did not have a connection string.
The key to Understanding this was learning of the "Switch to live mode" button from the data factory pipeline editor view:
After clicking this, I was able to browse the status of the linked service as were - rather than as per "development" mode.

Related

Not able to get Azure SQL Server Extended Events to work when Blob Storage is set to Enabled from selected virtual networks and IP addresses

So I have an Azure Database and want to test extended events with the database.
I was able to set up my Blob Storage container and was able to get Extended Events via Azure Database to work as long as the Blob Storage network setting Public network access is set to Enabled from all networks. If I set Enabled from selected virtual networks and IP addresses and have Microsoft network routing checked as well as Resource type set with Microsoft.Sql/servers and its value as All In current subscription, it still doesn't work.
I'm not exactly sure what I'm doing wrong and I'm not able to find any documentation on how to make it work without opening up to all networks.
The error I'm getting is:
The target, "5B2DA06D-898A-43C8-9309-39BBBE93EBBD.package0.event_file", encountered a configuration error during initialization. Object cannot be added to the event session. (null) (Microsoft SQL Server, Error: 25602)
Edit - Steps to fix the issue
#Imran: Your answer led me to get everything working. The information you gave and the link provided was enough for me to figure it out.
However, for anyone in the future I want to give better instructions.
The first step I had to do was:
All I had to do was run Set-AzSqlServer -ResourceGroupName [ResourcegroupName] b -ServerName [AzureSQLServerName] -AssignIdentity.
This assigns the SQL Server an Azure Active Directory Identity. After running the above command, you can see your new identity in Azure Active Directory under Enterprise applicationsand then where you see theApplication type == Enterprise Applicationsheader, click the headerApplication type == Enterprise Applicationsand change it toManaged Identities`and click apply. You should see your new identity.
The next step is to give your new identity the role of Storage Blob Data Contributor to your container in Blob Storage. You will need to go to your new container and click Access Control (IAM) => Role assignments => click Add => Add Role assignment => Storage Blob Data Contributor => Managed identity => Select member => click your new identity and click select and then Review + assign
The last step is to get SQL Server to use an identity when connecting to `Blob Storage.
You do that by running the command below on your Azure SQL Server database.
CREATE DATABASE SCOPED CREDENTIAL [https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>]
WITH IDENTITY = 'Managed Identity';
GO
You can see your new credentials when running
SELECT * FROM sys.database_scoped_credentials
The last thing I want to mention is when creating Extended Events with
an Azure SQL Server using SSMS, it gives you this link. This only works if you want your Blob Storage wide open. I think this is a disservice and wish they would have instructions when you want your Blob Storage not wide open by using RBAC instead of SAS.
I tried to reproduce the same in my environment I got the result successfully like below:
To resolve this issue, check whether your account type should be
StorageV2(general purpose v2). If you have a general-purpose v1 or blob storage account, try to upgrade like below.
In storage account -> under setting, configuration -> upgrade
Check whether you have choose Allow trusted Microsoft services to access this storage account under exception and I added firewall client Ip address range and vnet like below.
Make sure Microsoft.Authorization/roleAssignments/write permission in your storage account
After enabling firewall, we lose write access to the storage account and audit logs try to Resave the audit settings from the portal is required in order for auditing to function like below.
Note: Auditing to storage behind firewalls using user managed identity authentication type is not presently supported.
When I try to connect, I got result successfully like below:
Reference:
Configure extended events in SQL Azure to the blob storage with Private Endpoint - Microsoft Community Hub by Sakshi Gupta

Abp.io: 'Out of the box' Multi Tenancy - Fails to Connect - Separate SQL Database Connection String for each Tenant

I thought I'd try out the standard layered ASP.NET Core 3.1 Abp.io template available at: https://Abp.io
I've followed the setup instructions, running the migration scripts to create the host database in localdb, and am able to successfully load the UI.
I login with the default credentials, then I create a new Tenant under 'Tenant Management' in the UI. I specify a custom database connection string for that tenant.
I open SQL Server Management Studio and create an empty database matching this in localdb.
Next, I logout of the admin host user, then press 'switch tenant' and type in the tenant name I just created. It gets stuck on loading, and there's a bunch of SQL Exceptions, then finally it gives up and shows the unable to connect error.
What steps do I need to take to setup a separate database for a tenant? Are there any migration scripts I need to run after creating the empty database?
#Aidan, I think you need to run the DbMigrator again after creating a new Tenant using a newly introduced connection string. The migration tool should traverse the tenancy connection strings a apply the latest migration. Then you should be able to utilize the new Tenant. Hope that helps.

ASP.NET Web API database not created in localdb

I have created an asp.net web api 4.5.2 project and I can't find the database that it's using for adding users. The info in the connection string:
Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-WebApplicationTest2-20160906022916.mdf;Initial Catalog=aspnet-WebApplicationTest2-20160906022916;Integrated Security=True.
But when I check the app_data directory it's empty. Where can I find this database?
Database creation for templates are delayed until a request is sent.
Run your server and POST following JSON with Content-Type: application/json header to http://localhost:xxx/api/Account/Register:
{
"Email": "test#test.com",
"Password": "TestTest1!",
"ConfirmPassword": "TestTest1!"
}
You should get 200: OK.
I am using Advanced REST client.
After that database will be created in App_Data folder.
If server returned 200: OK and App_Data is empty, Do the following steps:
In Visual Studio go to View menu. Select SQL Server Object Explorer(or press Ctrl+\, Ctrl+S).
Your SQL server should be there. You can find your database in Databases folder.
If you need specifically the data file, then expand Databases folder, right click on which one you need and click on Properties. Scroll down to see Current Connection Parameters.
Some times this error occurred when you do not install local db of SQL server.To know if you install local db,open command prompt(administrator) and type "SqlLocalDb info".Then it show localdb name.add that name into connection string.If command prompt is not show this,refer following link to add localdb into SQL express server.
link:-https://www.mssqltips.com/sqlservertip/5612/getting-started-with-sql-server-2017-express-localdb/

Create data source in Report Builder 3.0 to a data cube using "current windows user" credentials

I have Report Builder 3.0 installed on my local PC. I am creating a new report and adding an embedded data source to a SQL Server Analysis Services database.
When I build the connection string of the data source, choosing the server name and the database name, I click 'Test Connection' and receive a message saying "Test connection succeeded". So far, so good.
I close the connection properties with the OK button, and on the Data Source Properties window I click the 'Test Connection' button. This time I get an error saying "The connection either timed out or was lost".
If I ignore the error then I can successfully add a dataset to my report and add data from the dataset in to the report design, but when I try to run the report (on my local PC) I again get an error connecting to the data source.
My best guess is that the connection that succeeded is running under my credentials, whereas the connection that fails is running as some other credential and so needs to use Kerberos delegation to pass my credentials along, but that is only a guess and even if I am correct I am at a loss to understand how to fix the issue - I don't know what other credentials may be being used and I have already set SPN's for the Analysis Services service account.
So it turns out that it was a Kerberos issue as I suspected, and I was also correct that Report Builder was testing the connection using some process running under another authentication context.
It turns out that when setting up Report Builder (and I had forgotten it) that you specify a default SSRS Report Server (see screenshot). It must be that when testing data sources or running reports that it connects to that default Report Server and does the work from there - I was assuming that everything was running locally!
Once I figured that out it was just a case of finding a good guide on how to configure SSRS for Kerberos and everything started working. In my case the only bit that I hadn't already done was to add the <RSWindowsNegotiate/> setting to the AuthenticationTypes in the rsreportserver.config file

How do I specify SSIS Package Database Connection Through Package Configurations?

I have an SQL 2005 SSIS package that takes data from an Oracle DB Table, and transfers it to a SQL Server Table.
I have set up an "Oracle Provider for OLE DB" for the Oracle connection and a "SQL Native Client" for SQL Server Connection.
The Oracle and SQL connections will depend on the development and shipping stage, which are:
Local environment
SYS - For integration and System testing
UAT - For user acceptance testing
PRE - Mimics the LIVE system for confidence testing
Live - The live system
In the Connection Manager for Oracle, it expects the following:
Server Name (which, for example can be DEVSERVER)
User Name (which, for example, can be devserver_user)
Password (which, for example, can be devserver_pass)
So, I was wondering how I could parameterise these such that the settings are picked up depending on the server. Ideally this would be a connection string that is stored in the registry (to have commonality with the architecture of other systems in our company).
I have attempted to specify the above settings through Package Configurations. I have also tried specifying the connection string, which would look something like this:
Provider=OraOLEDB.Oracle;Data Source=DEVSERVER;User ID=devserver_user;Password=devserver_pass;PLSQLRSet=1;OLE DB Services = -2;
I have tried this through a registry setting, environment settings, and XML config file. I am mapping these item to the properties on the connection object, but the settings do not seem to hold. I.e. when I open the connection object these settings are not there.
What happens is that when I open the OLE DB source and specify the connection, it fails, because the connection object is not picking up the items in the Package Configurations.
Is there something I am missing, some setting that I have to configure. I guess I'm not sure as to what I'm not seeing anything!
Any help would be appreciated.
Just worked this out this myself.
This really was a case of RTFM! The first paragraph on the MSDN Package Configurations page says it all:
Typically, you create a package set
properties on the package objects
during package development, and then
add the configuration to the package.
Still, I hope this is still of help to other RTFMers!