Connect to Azure SQL Database using a Service Principal
As an alternative to using standard SQL Login via username and password, PowerSync can connect to your Azure SQL Database using a Service Principal. Update yourconfig.yaml file to use the Service Principal for authentication:
config.yaml
Set up a Service Principal for Azure SQL Database
Set up a Service Principal for Azure SQL Database
Create a New App Registration
- Go to the Azure portal and navigate to App registrations >.
- Click New registration.
- Fill in the required fields:
- Name: Give your app user a name, e.g. “powersync_user”.
- Redirect URI: Leave this blank.
- Supported account types: Select Accounts in this organizational directory only.
- Click Register.
- Copy the Application (Client) ID and Directory (Tenant) ID.
Create a Client Secret
- Navigate to the app registration you created in the previous step.
- In the left navigation menu, under Manage, click Certificates & secrets.
- Click New client secret.
- Fill in the required fields:
- Description: Enter a description for the secret
- Expires: Select an expiration date
- Click Add.
- Important: Copy the Value - this is the client secret and will not be shown again.
Configure the Database User
- Connect to the SQL Server database using an account with administrative privileges.
- Create a new user linked to the app registration:
- Complete the rest of the user setup by following the instructions in Source Database Setup.
Additional Configuration Options
The below configuration options can be set in theadditionalConfig section under the connections section of the config.yaml file.
All of these configuration options are optional and can be omitted if the
default values are acceptable.
config.yaml