sql-serverazureprisma

Connecting Prisma to Azure SQL Database


I am trying to connect Prisma to an SQL Database in Azure. I noticed that my Azure SQL Database connection string does not look anything like the connection strings in the Prisma getting started document.

Server=tcp:mufdatabase.database.windows.net,1433;Initial Catalog=muf;Persist Security Info=False;User ID=muf;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

Whereas Prisma lists MS SQL Server connection string example as

sqlserver://localhost:1433;initial catalog=sample;user=sa;password=mypassword;

I thought Azure SQL Database was just an SQL Server so why would the connection strings be so different? Does Prisma support Azure SQL Database?


Solution

  • Microsoft SQL Server / Azure SQL support was announced as being generally available as part of prisma version 3.0.1 in a blog post from September 07, 2021:

    Today we are excited to announce that Prisma support for SQL Server and Azure SQL is Generally Available and ready for production workloads as part of the 3.0.1 release!

    And was (partially) available in preview since version 2.10.0 (Oct 28, 2020):

    Support for Microsoft SQL Server (Preview) With this release, we're introducing support for a new database: Microsoft SQL Server 🥳

    You can start using your MS SQL Server databases today with introspection and query them with Prisma Client. Note that Prisma Migrate does not support MS SQL Server yet.

    The prisma Microsoft SQL Server data source connector docs are available here, and we can see that it requires the connection strings to follow the JDBC standard.

    Your connection string appears to be in a .NET format, which if we split across newlines for clarity, looks like this:

    Server=tcp:mufdatabase.database.windows.net,1433;
    Initial Catalog=muf;
    Persist Security Info=False;
    User ID=muf;
    Password={your_password};
    MultipleActiveResultSets=False;
    Encrypt=True;
    TrustServerCertificate=False;
    Connection Timeout=30;
    

    We can see a list of connection string properties for the JDBC driver here, which we can use to convert the above connection string to JDBC standard format, which should look something like this (split across new lines for clarity):

    sqlserver://mufdatabase.database.windows.net:1433;
    database=muf;
    user=muf;
    password={your_password};
    encrypt=true;
    trustServerCertificate=false;
    hostNameInCertificate=*.database.windows.net;
    loginTimeout=30;
    

    With some options seemingly not existing within the JDBC driver: