Skip to content

Files

Latest commit

7b8a758 · Jun 6, 2022

History

History
144 lines (109 loc) · 10.5 KB

how-to-integrate-sql-database.md

File metadata and controls

144 lines (109 loc) · 10.5 KB
title description author ms.author ms.service ms.topic ms.date
Integrate Azure SQL Database with Service Connector
Integrate SQL into your application with Service Connector
maud-lv
malev
service-connector
how-to
06/02/2022

Integrate Azure SQL Database with Service Connector

This page shows all the supported compute services, clients, and authentication types to connect services to Azure SQL Database instances, using Service Connector. This page also shows the default environment variable names and application properties needed to create service connections. You might still be able to connect to an Azure SQL Database instance using other programming languages, without using Service Connector. Learn more about the Service Connector environment variable naming conventions.

Supported compute services

  • Azure App Service
  • Azure Spring Cloud

Supported authentication types and clients

Client type System-assigned managed identity User-assigned managed identity Secret/connection string Service principal
.NET yes icon
Go yes icon
Java yes icon
Java - Spring Boot yes icon
PHP yes icon
Node.js yes icon
Python yes icon
Python - Django yes icon
Ruby yes icon

Default environment variable names or application properties

Use the environment variable names and application properties listed below to connect a service to Azure SQL Database using a secret and a connection string.

Connect an Azure App Service instance

Use the connection details below to connect Azure App Service instances with .NET, Go, Java, Java - Spring Boot, PHP, Node.js, Python, Python - Django and Ruby. For each example below, replace the placeholder texts <sql-server>, <sql-db>, <sql-user>, and <sql-pass> with your server name, database name, user ID and password.

Azure App Service with .NET (sqlClient)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_CONNECTIONSTRING Azure SQL Database connection string Data Source=<sql-server>.database.windows.net,1433;Initial Catalog=<sql-db>;User ID=<sql-user>;Password=<sql-pass>

Azure App Service with Java Database Connectivity (JDBC)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_CONNECTIONSTRING Azure SQL Database connection string jdbc:sqlserver://<sql-server>.database.windows.net:1433;databaseName=<sql-db>;user=<sql-user>;password=<sql-pass>;

Azure App Service with Java Spring Boot (spring-boot-starter-jdbc)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
spring.datasource.url Azure SQL Database datasource URL jdbc:sqlserver://<sql-server>.database.windows.net:1433;databaseName=<sql-db>;
spring.datasource.username Azure SQL Database datasource username <sql-user>
spring.datasource.password Azure SQL Database datasource password <sql-pass>

Azure App Service with Go (go-mssqldb)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_CONNECTIONSTRING Azure SQL Database connection string server=<sql-server>.database.windows.net;port=1433;database=<sql-db>;user id=<sql-user>;password=<sql-pass>;

Azure App Service with Node.js

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_SERVER Azure SQL Database server <sql-server>.database.windows.net
AZURE_SQL_PORT Azure SQL Database port 1433
AZURE_SQL_DATABASE Azure SQL Database database <sql-db>
AZURE_SQL_USERNAME Azure SQL Database username <sql-user>
AZURE_SQL_PASSWORD Azure SQL Database password <sql-pass>

Azure App Service with PHP

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_SERVERNAME Azure SQL Database servername <sql-server>.database.windows.net
AZURE_SQL_DATABASE Azure SQL Database database <sql-db>
AZURE_SQL_UID Azure SQL Database unique identifier (UID) <sql-user>
AZURE_SQL_PASSWORD Azure SQL Database password <sql-pass>

Azure App Service with Python (pyobdc)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_SERVER Azure SQL Database server <sql-server>.database.windows.net
AZURE_SQL_PORT Azure SQL Database port 1433
AZURE_SQL_DATABASE Azure SQL Database database <sql-db>
AZURE_SQL_USER Azure SQL Database user <sql-user>
AZURE_SQL_PASSWORD Azure SQL Database password <sql-pass>

Azure App Service with Django (mssql-django)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_HOST Azure SQL Database host <sql-server>.database.windows.net
AZURE_SQL_PORT Azure SQL Database port 1433
AZURE_SQL_NAME Azure SQL Database name <sql-db>
AZURE_SQL_USER Azure SQL Database user <sql-user>
AZURE_SQL_PASSWORD Azure SQL Database password <sql-pass>

Azure App Service with Ruby

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
AZURE_SQL_HOST Azure SQL Database host <sql-server>.database.windows.net
AZURE_SQL_PORT Azure SQL Database port 1433
AZURE_SQL_DATABASE Azure SQL Database database <sql-db>
AZURE_SQL_USERNAME Azure SQL Database username <sql-user>
AZURE_SQL_PASSWORD Azure SQL Database password <sql-pass>

Connect an Azure Spring Cloud instance

Use the connection details below to connect Azure Spring Cloud instances with Java Spring Boot.

Azure Spring Cloud with Java Spring Boot (spring-boot-starter-jdbc)

[!div class="mx-tdBreakAll"]

Default environment variable name Description Sample value
spring.datasource.url Azure SQL Database datasource URL jdbc:sqlserver://<sql-server>.database.windows.net:1433;databaseName=<sql-db>;
spring.datasource.username Azure SQL Database datasource username <sql-user>
spring.datasource.password Azure SQL Database datasource password <sql-pass>

Next steps

Follow the tutorial listed below to learn more about Service Connector.

[!div class="nextstepaction"] Learn about Service Connector concepts