Product:
Azure Data Factory (ADF)
Issue:
Can not connect to SQL server from ADF in same subscription.
Cannot connect to SQL Database: ‘databaseservername.database.windows.net‘, Database: ‘databasename‘, Reason: Connection was denied since Deny Public Network Access is set to Yes. To connect to this server,
1. If you persist public network access disabled, please use Managed Virtual Network IR and create private endpoint. https://docs.microsoft.com/en-us/azure/data-factory/managed-virtual-network-private-endpoint; https://docs.microsoft.com/en-us/azure/data-factory/tutorial-copy-data-portal-private;
2. Otherwise you can enable public network access, set “Public network access” option to “Selected networks” on Auzre SQL Networking setting.
Solution:
Prompt yourself to Owner in the subscription and ADF.
Inside ADF you need first ensure that Integration Run-times are using a Managed Virtual Network. Create a new Integration runtime setup,
select Azure. self-hosted.
select Azure
set region to your needs, and click create.
When this use Managed Virtual Network, you can go and create the Linked Service.
Select Azure SQL database.
In connect drop-down select the above created integrationruntime2 that have managed virtual network.
Select your Azure Subscription.
Select your database server name from the drop-down.
Select the database name.
Select the Authentication type to be “System Assigned Managed Identity”
Click Test, and if there is OK, click Create.
Then you may inside SSMS add the ADF managed user to the database with command similar to this:
In master database:
CREATE login [adf_user] FROM EXTERNAL PROVIDER CREATE USER [adf_user] FROM LOGIN [adf_user] WITH DEFAULT_SCHEMA=[dbo]
In user database:
CREATE USER [adf_user] FROM LOGIN [adf_user] ALTER ROLE [db_owner] ADD MEMBER [adf_user]
More Information:
https://learn.microsoft.com/en-us/azure/data-factory/managed-virtual-network-private-endpoint
https://lazyadmin.nl/office-365/how-to-use-azure-managed-identity/
https://www.inthecloud247.com/configure-a-user-assigned-managed-identity-the-basics/