Azure SQL Edge will be retired on September 30, 2025. For more information and migration options, see the Retirement notice.
Napomena
Azure SQL Edge no longer supports the ARM64 platform.
In this quickstart, you use Docker to pull and run the Azure SQL Edge container image. Then connect with sqlcmd to create your first database and run queries.
This image consists of SQL Edge based on Ubuntu 18.04. It can be used with the Docker Engine 1.8+ on Linux.
Azure SQL Edge containers aren't supported on the following platforms for production workloads:
Windows
macOS
Azure IoT Edge for Linux on Windows (EFLOW)
Prerequisites
Docker Engine 1.8+ on any supported Linux distribution. For more information, see Install Docker. Since the SQL Edge images are based on Ubuntu 18.04, we recommended that you use an Ubuntu 18.04 Docker host.
Docker overlay2 storage driver. This is the default for most users. If you find that you aren't using this storage provider and need to change, see the instructions and warnings in the Docker documentation for configuring overlay2.
For the bash commands in this article sudo is used. If you don't want to use sudo to run Docker, you can configure a Docker group and add users to that group. For more information, see Post-installation steps for Linux.
Pull and run the container image
Pull the Azure SQL Edge container image from Microsoft Container Registry.
The password should follow the Microsoft SQL Database Engine default password policy, otherwise the container can't set up the SQL Database Engine and will stop working. By default, the password must be at least 8 characters long and contain characters from three of the following four sets: uppercase letters, lowercase letters, base-10 digits, and symbols. You can examine the error log by executing the docker logs command.
The following table provides a description of the parameters in the previous docker run examples:
Parameter
Description
-e "ACCEPT_EULA=Y"
Set the ACCEPT_EULA variable to any value to confirm your acceptance of the End-User Licensing Agreement. Required setting for the SQL Edge image.
-e "MSSQL_SA_PASSWORD=<password>"
Specify your own strong password that is at least eight characters and meets the password requirements. Required setting for the SQL Edge image.
-p 1433:1433
Map a TCP port on the host environment (first value) with a TCP port in the container (second value). In this example, SQL Edge is listening on TCP 1433 in the container and this is exposed to the port, 1433, on the host.
--name azuresqledge
Specify a custom name for the container rather than a randomly generated one. If you run more than one container, you can't reuse this same name.
To view your Docker containers, use the docker ps command.
sudo docker ps -a
If the STATUS column shows a status of Up, then SQL Edge is running in the container and listening on the port specified in the PORTS column. If the STATUS column for your SQL Edge container shows Exited, see the Troubleshooting section of Azure SQL Edge documentation.
The -h (host name) parameter is also useful, but it isn't used in this tutorial for simplicity. This changes the internal name of the container to a custom value. This is the name that is returned in the following Transact-SQL query:
Setting -h and --name to the same value is a good way to easily identify the target container.
As a final step, change your SA password because the MSSQL_SA_PASSWORD is visible in ps -eax output and stored in the environment variable of the same name. See the following steps.
Change the SA password
The SA account is a system administrator on the Azure SQL Edge instance that gets created during setup. After you create your SQL Edge container, the MSSQL_SA_PASSWORD environment variable you specified is discoverable by running echo $MSSQL_SA_PASSWORD in the container. For security purposes, change your SA password.
Choose a strong password to use for the SA user.
Use docker exec to run sqlcmd to change the password using Transact-SQL. In the following example, replace the old password, <old-password>, and the new password, <new-password>, with your own password values.
sudo docker exec -it azuresqledge /opt/mssql-tools/bin/sqlcmd \
-S localhost -U SA -P "<old-password>" \
-Q 'ALTER LOGIN SA WITH PASSWORD="<new-password>"'
Connect to Azure SQL Edge
The following steps use the Azure SQL Edge command-line tool, sqlcmd, inside the container to connect to SQL Edge.
Use the docker exec -it command to start an interactive bash shell inside your running container. In the following example, azuresqledge is the name specified by the --name parameter when you created the container.
sudo docker exec -it azuresqledge "bash"
Once inside the container, connect locally with sqlcmd. sqlcmd isn't in the path by default, so you have to specify the full path.
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<password>"
Savjet
You can omit the password on the command-line to be prompted to enter it.
If successful, you should get to a sqlcmd command prompt: 1>.
Create and query data
The following sections walk you through using sqlcmd and Transact-SQL to create a new database, add data, and run a query.
Create a new database
The following steps create a new database named TestDB.
From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:
CREATE DATABASE TestDB;
GO
On the next line, write a query to return the name of all of the databases on your server:
SELECT name from sys.databases;
GO
Insert data
Next create a new table, Inventory, and insert two new rows.
From the sqlcmd command prompt, switch context to the new TestDB database:
USE TestDB;
Create new table named Inventory:
CREATE TABLE Inventory (
id INT,
name NVARCHAR(50),
quantity INT
);
Insert data into the new table:
INSERT INTO Inventory
VALUES (1, 'banana', 150);
INSERT INTO Inventory
VALUES (2, 'orange', 154);
Type GO to execute the previous commands:
GO
Select data
Now, run a query to return data from the Inventory table.
From the sqlcmd command prompt, enter a query that returns rows from the Inventory table where the quantity is greater than 152:
SELECT * FROM Inventory WHERE quantity > 152;
Execute the command:
GO
Exit the sqlcmd command prompt
To end your sqlcmd session, type QUIT:
QUIT
To exit the interactive command-prompt in your container, type exit. Your container continues to run after you exit the interactive bash shell.
Connect from outside the container
You can also connect to the SQL Edge instance on your Docker machine from any external Linux, Windows, or macOS tool that supports SQL connections. For more information on connecting to a SQL Edge container from outside, see Connect and Query Azure SQL Edge.
Remove your container
If you want to remove the SQL Edge container used in this tutorial, run the following commands:
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.