How to query on-premises SQL Server database from Azure SQL database? - sql-server

I'm trying to query an on-premises SQL Server database from an Azure SQL database. I understand that the elastic query feature allows you to query across multiple databases in Azure SQL Database. But, it doesn't work with querying an on-premises database. Is there any way to do this?

Elastic database queries work between Azure SQL Databases and to query Azure SQL Data Warehouse only. From an architecture point of view on the scenario you describe, Azure would be relying on a server outside of its infrastructure to satisfy a query, if elastic queries were allowing creating external data sources to on-premises SQL Server instances. A better architecture may be replicating the on-premises database to a hub database on Azure SQL using SQL Data Sync and then create elastic queries using that hub database. Even from a performance point of view makes more sense, since queries won't be executing against your on-premises databases and latency will be less a factor.
Another option you have is to consider using Azure Managed Instance with allows you to create Linked Servers that can connect to on-premises databases as you can read here. Azure Managed Instance supports running on a private VNet, from which it's reasonable to connect to on-premises SQL Server instances. Azure SQL Database would have no way to communicate with your on-premises servers.

Related

ETL / Replication from Azure SQL Database to on-premises SQL Server data warehouse

I'm trying to build daily ETL process from Azure SQL Database to on-premises SQL Server data warehouse.
I have experience in ETL between on-premises SQL Servers but when it comes to Azure I'm not sure the best practise. I did some researches and got the options on ETL and ADP.
Would anyone here have similar experience before, could shed me some lights? Any comment, example or tutorial are much appreciated.
There are many ways can help you build daily ETL process from Azure SQL Database to on-premises SQL Server data warehouse.
I would suggest you think about Azure Data Factory or Azure SQL database Data Sync.
Data Factory can help you build a pipeline to copy the data between Azure SQL database and On-premise SQL Server. You could create a time trigger to trigger the copy daily. Ref these documents:
Copy and transform data in Azure SQL Database by using Azure Data
Factory
Copy data to and from SQL Server by using Azure Data Factory
Data Sync is a feature of Azure SQL database, you can sync the data between SQL database and on-premise SQL Server automatically. I think that's the easiest and cheapest way which can achieve your request in some way. Just note the requirements and limitations.
And like #Nick said, Azure SQL database doesn't support windows authentication, please use SQL authentication or AD.
HTH.

Is it possible to query the Active Directory from Azure SQL

I am migrating from an older version of Microsoft SQL to Azure SQL. The existing SQL Server stored procedures use OPENQUERY and a linked ADSI server to retrieve user information directly from the Active Directory.
Is this possible in Azure SQL?
Azure SQL Database only allows to query another Azure SQL Database (remote) or Azure Synapse Analytics databases using elastic queries. All other SQL and non-SQL sources are not allowed.
Azure Managed Instance uses a private VNET and supports linked servers to a limited number of targets. Supported targets: SQL Server and SQL Database. Not supported targets: Active Directory, files, Excel, Oracle, MySQL, Analysis Services, and other RDBMS.
Azure SQL Database would have no way to communicate with your on-premises servers since it does not uses private VNETs as Managed Instance does.
If you rely heavily on this you should discard all Azure SQL (PaaS) options and go for a SQL Server Azure VM.

Any options to connect from Azure SQL Server database to an Azure Data Warehouse instance

We want to be able to query the Data Warehouse database from the SQL Server database both with the same server name in Azure. Select statements including the database name (e.g. select * from server.dbo.product) returns with error that a reference to the database and/or server name isn't supported in this version of SQL Server. There are articles on creating an external data source in the SQL Server database but we get error that the credentials don't have permission to perform this action.
Azure SQL (as of Azure SQL V12 in late-2016) does not support cross-database queries the same way that they do with a normal on-premises SQL Server (e.g. using the DatabaseName.schemaName.TableName syntax).
Given that Azure SQL and Azure Data Warehouse databases each reside in different physical servers it wouldn't work anyway, as the above syntax is intended for databases that all reside in the same server.
Azure SQL does support cross-database calls via the EXTERNAL DATA SOURCE feature, which we have in normal on-premises SQL Server already. This is documented here: https://azure.microsoft.com/en-us/blog/querying-remote-databases-in-azure-sql-db/
Note that performance won't be that great and you might be better-off doing the querying in your application code. For example complex JOINs which reduce data will run suboptimally.

What is best practise to migrate On-premises SQL Server to Azure VM - Dynamic SQL Agent Jobs in AlwaysOn offering

I am trying to migrate On-premises SQL Server to Azure VM.
I am writing in reference to below link
https://azure.microsoft.com/en-in/documentation/articles/virtual-machines-migrate-onpremises-database/#azure-vm-deployment-wizard-tutorial
I am having multiple applications in which few are hosted in Azure and few are On-premises.
All these applications contact on-premise SQL Server for data manipulations.
In some scenario these applications creates dynamic SQL Agent Jobs!
Now my requirement is to move on-premise SQL Server to Azure cloud. I would like to know how can I manage these dynamic SQL Agents in Azure?
In short, My question is: how can I migrate below items?
SSIS packages associated with these databases
SQL Agent Jobs scheduled in server (created dynamically)
File Stream associated with server databases
Also I am planning to use SQL Server "AlwaysOn" offering. So how to synch these SQL Agent Jobs in these shared Virtual Machines?
I was referring https://azure.microsoft.com/en-us/documentation/articles/sql-database-general-limitations/ and it says as follow
Microsoft Azure SQL Database does not support SQL Server Agent or
jobs. You can, however, run SQL Server Agent on your on-premises SQL
Server and connect to Microsoft Azure SQL Database.
SQL Agents can be dynamically created as shown here https://www.mssqltips.com/sqlservertip/3052/simple-way-to-create-a-sql-server-job-using-tsql/ My question is, will these stored procedures run in azure cloud?
Update
It’s challenge but can be done. We need to setup new Job, which constantly monitors and pull the current role of the replica, based on PRIMARY role, we run the job needs to do if it is the primary.
Below link gives me hint
https://dba.stackexchange.com/questions/45137/sql-server-agent-jobs-and-availability-groups but I am looking for step by step blog/article to achieve this.

Need to select best Azure service to access on-premises sql database

I have a business scenario where web site and SQL database will be on cloud and after some operations want to save the cloud SQL data to the SQL database which is on-premises and not exposed to the internet.
What would be the best architecture for this scenario?
Need suggestions.
you can either setup a VNET to connect your Website to your on-premises SQL Server or you can configure Azure Hybrid Connect. (see this link)
If the website does not use local resources you can always go for azure websites. Choose the tier based on the requirement.
As far as the database is concerned you choose azure sql database. ( tier based on requirement-size and performance) . You can set up azure sql sync (in preview) to sync between sql azure and local sql server. Or you can take a back up of sql azure db - bacpac. and then restore it local sql server using sql management studio.

Resources