Azure SQL Database Setup Guide
Follow these instructions to replicate your Azure SQL database to your destination via Fivetran.
To connect your SQL Server database to Fivetran, you need:
- SQL Server version 2012 or above
- IP (e.g. 184.108.40.206) or host (your.server.com)
- Port (usually 1433)
Choose a connection method
Decide whether to connect your SQL Server database directly or using an SSH tunnel.
Fivetran connects directly to your database instance. This is the simplest and most secure connection method.
To connect directly, create a firewall rule to allow access to Fivetran's IP.
Connect using SSH
Fivetran connects to a separate server in your network that provides an SSH tunnel to your database. You must connect through SSH if your database is in an inaccessible subnet on a virtual network.
To connect using SSH, create a firewall rule to allow access to your SSH tunnel server's IP address.
Fivetran's data processing servers need access to your database server. You must configure the firewall.
Configure server firewall
Open the SQL database firewall settings in the Azure console.
Select SQL databases in the left menu, then select the SQL database that you want to replicate.
Click Set server firewall.
Add a new firewall rule
Add a new firewall rule and save. Use Fivetran's IP if you are connecting directly or your SSH tunnel server's IP address if you are connecting using SSH.
Enter host and port in setup form
In your Fivetran setup form, enter the host and port.
Server namein the Azure database dashboard overview.
Create a Fivetran user
Run the following command to add a container database user. Replace
<database> with the name of your database and
<password> with a password of your choice:
USE [<database>]; CREATE USER fivetran WITH PASSWORD = '<password>';
Grant user permissions
Once you've created the
fivetran user, grant it SELECT permission for the database, schemas, tables, or specific columns you want Fivetran to sync. You can grant access to everything in a given database:
GRANT SELECT on DATABASE::[<database>] to fivetran;
or all tables in a given schema:
GRANT SELECT on SCHEMA::[<schema>] to fivetran;
or a specific table:
GRANT SELECT ON [<schema>].[<table>] TO fivetran;
or a set of specific columns in a table:
GRANT SELECT ON [<schema>].[<table>] ([<column 1>], [<column 2>], ...) TO fivetran;
or all but a set set of specific columns in a table:
GRANT SELECT ON [<schema>].[<table>] TO fivetran; DENY SELECT ON [<schema>].[<table>] ([<column X>], [<column Y>], ...) TO fivetran;
Enter user, password, and database in setup form
In your Fivetran setup form, enter your user, password, and database name.
- For the User, enter
<servername>is part of your Azure host URL:
- For the Password, enter the password you set when you created the user.
- For the Database, enter the name of the database you want to replicate from.
Enable incremental updates
We use one of SQL Server's two built-in tracking mechanisms for incremental updates: change tracking (CT) and change data capture (CDC). When enabled, both CT and CDC keep a record of the table rows that have changed in a certain window of time (the default window is the most recent 2 days). These mechanisms let Fivetran copy only the rows that have changed since the last data sync so we don't have to copy the whole table every time.
Choose to enable either change tracking or change data capture. To learn more about CT and CDC, see our updating data documentation.
Enable change tracking at the database level:
ALTER DATABASE [<database>] SET CHANGE_TRACKING = ON;
Enable change tracking for each table you want to integrate:
ALTER TABLE [<schema>].[<table>] ENABLE CHANGE_TRACKING;
VIEW CHANGE TRACKINGpermission for each of the tables that have change tracking enabled:
GRANT VIEW CHANGE TRACKING ON [<schema>].[<table>] TO fivetran;
Change tracking needs to be enabled at this step before continuing.
Change data capture
Enable change data capture at the database level:
USE [<database>]; EXEC sys.sp_cdc_enable_db;
Enable change data capture for each table you want to integrate:
EXEC sys.sp_cdc_enable_table @source_schema = [<schema>], @source_name = [<table>], @role_name = [<role>];
Note: Fivetran only supports tables with a single CDC capture instance that includes every column.
Choose schema prefix
Each database from your source will be mapped to a schema in the destination by adding a prefix to the source database name. For example, if your source database names are "foo" and "bar" and if you choose the prefix "source1", then you will get schemas "source1_foo" and "source1_bar" in the destination.