|
| 1 | +--- |
| 2 | +title: Integrate SQL database in Microsoft Fabric with Service Connector |
| 3 | +description: Integrate SQL database in Microsoft Fabric with Service Connector |
| 4 | +author: maud-lv |
| 5 | +ms.author: malev |
| 6 | +ms.service: service-connector |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 02/27/2025 |
| 9 | +--- |
| 10 | + |
| 11 | +# Integrate SQL database in Microsoft Fabric with Service Connector |
| 12 | + |
| 13 | +This page shows supported authentication methods and clients, and shows sample code you can use to connect your apps to SQL database in Microsoft Fabric using Service Connector. This page also shows default environment variable names and values you get when you create the service connection. |
| 14 | + |
| 15 | +## Supported compute services |
| 16 | + |
| 17 | +Service Connector can be used to connect the following compute services to SQL database in Fabric: |
| 18 | + |
| 19 | +- Azure App Service |
| 20 | +- Azure Container Apps |
| 21 | +- Azure Functions |
| 22 | +- Azure Kubernetes Service (AKS) |
| 23 | + |
| 24 | +## Supported authentication types and client types |
| 25 | + |
| 26 | +The following table shows which combinations of authentication methods and clients are supported for connecting your compute service to SQL database in Fabric using Service Connector. A "Yes" indicates that the combination is supported, while a "No" indicates that it is not supported. |
| 27 | + |
| 28 | +| Client type | System-assigned managed identity | User-assigned managed identity | Secret/connection string | Service principal | |
| 29 | +|--------------------|:--------------------------------:|:------------------------------:|:------------------------:|:-----------------:| |
| 30 | +| .NET | Yes | Yes | No | No | |
| 31 | +| Go | Yes | Yes | No | No | |
| 32 | +| Java | Yes | Yes | No | No | |
| 33 | +| Java - Spring Boot | Yes | Yes | No | No | |
| 34 | +| Python | Yes | Yes | No | No | |
| 35 | +| None | Yes | Yes | No | No | |
| 36 | + |
| 37 | +This table indicates that as per Fabric behavior, only authentication via managed identities is allowed. |
| 38 | + |
| 39 | +The system-assigned managed identity and user-assigned managed identity methods are supported for .NET, Java, Java - Spring Boot, Python, Go, and None client types. These methods are not supported for any other types. |
| 40 | + |
| 41 | +> [!IMPORTANT] |
| 42 | +> Manual access sharing is currently required for complete onboarding. See [Share access to SQL database in Fabric](#share-access-to-sql-database-in-fabric). |
| 43 | +
|
| 44 | +## Default environment variable names or application properties and sample code |
| 45 | + |
| 46 | +Refer to the connection details and sample code presented in the following tabs to connect compute services to SQL database in Fabric. For more information about naming conventions, check the [Service Connector internals](concept-service-connector-internals.md#configuration-naming-convention) article. |
| 47 | + |
| 48 | +> [!NOTE] |
| 49 | +> Although SQL database in Fabric is distinct from Azure SQL Database, you can connect to and query your SQL database in Fabric in all the same ways as Azure SQL Database. [Learn more](/fabric/database/sql/connect). |
| 50 | +
|
| 51 | +### System-assigned managed identity |
| 52 | + |
| 53 | +#### [.NET](#tab/fabric-sql-me-id-dotnet) |
| 54 | + |
| 55 | +| Default environment variable name | Description | Example value | |
| 56 | +| --------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | |
| 57 | +| `FABRIC_SQL_CONNECTIONSTRING ` | Azure SQL Database connection string | `Data Source=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;Initial Catalog=<SQL-DB-name>-<Fabric-DB-Identifier>;Authentication=ActiveDirectoryManagedIdentity` | |
| 58 | + |
| 59 | +#### [Java](#tab/fabric-sql-me-id-java) |
| 60 | + |
| 61 | +| Default environment variable name | Description | Sample value | |
| 62 | +|-----------------------------------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------| |
| 63 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `jdbc:sqlserver://<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;databaseName=<SQL-DB-name>-<Fabric-DB-Identifier>;authentication=ActiveDirectoryMSI;` | |
| 64 | + |
| 65 | +#### [SpringBoot](#tab/fabric-sql-me-id-springboot) |
| 66 | + |
| 67 | +| Default environment variable name | Description | Sample value | |
| 68 | +|-----------------------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------| |
| 69 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `jdbc:sqlserver://<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;databaseName=<SQL-DB-name>-<Fabric-DB-Identifier>;authentication=ActiveDirectoryMSI;` | |
| 70 | + |
| 71 | +#### [Python](#tab/fabric-sql-me-id-python) |
| 72 | + |
| 73 | +| Default environment variable name | Description | Example value | |
| 74 | +| --------------------------------- | ----------------- | -------------------------------------------- | |
| 75 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `Driver={ODBC Driver 17 for SQL Server};Server=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;Database=<SQL-DB-name>-<Fabric-DB-Identifier>;Authentication=ActiveDirectoryMSI;` | |
| 76 | + |
| 77 | +#### [Go](#tab/fabric-sql-me-id-go) |
| 78 | + |
| 79 | +| Default environment variable name | Description | Example value | |
| 80 | +| --------------------------------- | ------------------------------- | -------------------------------------------------------------------------- | |
| 81 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `server=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com;port=1433;database=<SQL-DB-name>-<Fabric-DB-Identifier>;fedauth=ActiveDirectoryManagedIdentity;` | |
| 82 | + |
| 83 | +#### [Other](#tab/fabric-sql-me-id-none) |
| 84 | +| Default environment variable name | Description | Example value | |
| 85 | +| --------------------------------- | ----------------- | -------------------------------------------- | |
| 86 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `server=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com;port=1433;database=<SQL-DB-name>-<Fabric-DB-Identifier>;fedauth=ActiveDirectoryManagedIdentity;` | |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +#### Sample code |
| 91 | + |
| 92 | +Outlined below are the steps and code snippets to connect to SQL database in Fabric using a system-assigned managed identity. |
| 93 | +[!INCLUDE [code sample for fabricsql system mi](./includes/code-fabricsql-me-id.md)] |
| 94 | + |
| 95 | +### User-assigned Managed Identity |
| 96 | + |
| 97 | +#### [.NET](#tab/fabric-sql-me-id-dotnet) |
| 98 | + |
| 99 | +| Default environment variable name | Description | Example value | |
| 100 | +| --------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | |
| 101 | +| `FABRIC_SQL_CONNECTIONSTRING ` | Azure SQL Database connection string | `Data Source=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;Initial Catalog=<SQL-DB-name>-<Fabric-DB-Identifier>;User ID=<msiClientId>;Authentication=ActiveDirectoryManagedIdentity` | |
| 102 | + |
| 103 | +#### [Java](#tab/fabric-sql-me-id-java) |
| 104 | + |
| 105 | +| Default environment variable name | Description | Sample value | |
| 106 | +|-----------------------------------|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------| |
| 107 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `jdbc:sqlserver://<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;databaseName=<SQL-DB-name>-<Fabric-DB-Identifier>;msiClientId=<msiClientId>;authentication=ActiveDirectoryMSI;` | |
| 108 | + |
| 109 | +#### [SpringBoot](#tab/fabric-sql-me-id-springboot) |
| 110 | + |
| 111 | +| Default environment variable name | Description | Sample value | |
| 112 | +|-----------------------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------| |
| 113 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `jdbc:sqlserver://<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;databaseName=<SQL-DB-name>-<Fabric-DB-Identifier>;msiClientId=<msiClientId>;authentication=ActiveDirectoryMSI;` | |
| 114 | + |
| 115 | +#### [Python](#tab/fabric-sql-me-id-python) |
| 116 | + |
| 117 | +| Default environment variable name | Description | Example value | |
| 118 | +| --------------------------------- | ----------------- | -------------------------------------------- | |
| 119 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `Driver={ODBC Driver 17 for SQL Server};Server=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com,1433;Database=<SQL-DB-name>-<Fabric-DB-Identifier>;UID=<msiClientId>;Authentication=ActiveDirectoryMSI;` | |
| 120 | + |
| 121 | +#### [Go](#tab/fabric-sql-me-id-go) |
| 122 | + |
| 123 | +| Default environment variable name | Description | Example value | |
| 124 | +| --------------------------------- | ------------------------------- | -------------------------------------------------------------------------- | |
| 125 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `server=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com;port=1433;database=<SQL-DB-name>-<Fabric-DB-Identifier>;user id=<msiClientId>;fedauth=ActiveDirectoryManagedIdentity;` | |
| 126 | + |
| 127 | +#### [Other](#tab/fabric-sql-me-id-none) |
| 128 | +| Default environment variable name | Description | Example value | |
| 129 | +| --------------------------------- | ----------------- | -------------------------------------------- | |
| 130 | +| `FABRIC_SQL_CONNECTIONSTRING` | Azure SQL Database connection string | `server=tcp:<Fabric-SQL-Identifier>.msit-database.fabric.microsoft.com;port=1433;database=<SQL-DB-name>-<Fabric-DB-Identifier>;user id=<msiClientId>;fedauth=ActiveDirectoryManagedIdentity;` | |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +#### Sample code |
| 135 | + |
| 136 | +Outlined below are the steps and code snippets to connect to SQL database in Fabric using a user-assigned managed identity. |
| 137 | +[!INCLUDE [code sample for fabricsql user mi](./includes/code-fabricsql-me-id.md)] |
| 138 | + |
| 139 | +## Share access to SQL database in Fabric |
| 140 | + |
| 141 | +1. Complete creating your service connection on the Cloud Shell, or on your local Azure CLI. |
| 142 | + |
| 143 | +1. Once your connection is created, open your compute service resource in the Azure portal, open the Service Connector menu, and locate your SQL database in Fabric service connection. Select **SQL database** to navigate to the Fabric portal. |
| 144 | + |
| 145 | + :::image type="content" source="./media/integrate-fabric-sql/navigate-to-fabric-sql-database.png" alt-text="Screenshot of the Azure portal, selecting SQL Database link to navigate to the Fabric portal."::: |
| 146 | + |
| 147 | +1. On the Fabric portal, locate the **Security** tab and select **Manage SQL security**. |
| 148 | + |
| 149 | + :::image type="content" source="./media/integrate-fabric-sql/fabric-portal-manage-security.png" alt-text="Screenshot of the Fabric portal, selecting Manage SQL Security."::: |
| 150 | + |
| 151 | +1. Select the role db_ddladmin, then **Manage access**. |
| 152 | + |
| 153 | + :::image type="content" source="./media/integrate-fabric-sql/fabric-portal-manage-access-sql-role.png" alt-text="Screenshot of the Fabric portal, selecting the db_ddladmin role, and then clicking Manage access."::: |
| 154 | + |
| 155 | +1. You should see the name of your system-assigned managed identity, and/or any user-assigned managed identities with a service connection to this SQL database in Fabric. Select **Share database**. If you do not see the **Share database** option, you do not need to continue with the remaining steps. |
| 156 | + |
| 157 | + :::image type="content" source="./media/integrate-fabric-sql/fabric-portal-share-database.png" alt-text="Screenshot of the Fabric portal, viewing a list of groups added to the role, and clicking Share database."::: |
| 158 | + |
| 159 | +1. Enter and select the name of your newly created system-assigned managed identity, and/or any user-assigned managed identities as they appear on the **Manage access** pane. Add any other identities as needed. Select the **Read all data using SQL database** checkbox, then select **Grant**. |
| 160 | + |
| 161 | + :::image type="content" source="./media/integrate-fabric-sql/fabric-portal-grant-access-type-name.png" alt-text="Screenshot of the Fabric portal, typing in the names of any assigned managed identities, selecting Read all data using SQL database, and then clicking Grant."::: |
| 162 | + |
| 163 | +1. You're now ready to use your new service connection to SQL database in Fabric. |
| 164 | + |
| 165 | +## Next step |
| 166 | + |
| 167 | +Refer to the following article to learn more about Service Connector. |
| 168 | + |
| 169 | +> [!div class="nextstepaction"] |
| 170 | +> [Learn about Service Connector concepts](./concept-service-connector-internals.md) |
0 commit comments