Deploy Azure SQL Edge
Important
Azure SQL Edge no longer supports the ARM64 platform.
Azure SQL Edge is a relational database engine optimized for IoT and Azure IoT Edge deployments. It provides capabilities to create a high-performance data storage and processing layer for IoT applications and solutions. This quickstart shows you how to get started with creating an Azure SQL Edge module through Azure IoT Edge using the Azure portal.
Before you begin
- If you don't have an Azure subscription, create a free account.
- Sign in to the Azure portal.
- Create an Azure IoT Hub.
- Create an Azure IoT Edge device.
Note
To deploy an Azure Linux VM as an IoT Edge device, see this quickstart guide.
Deploy SQL Edge Module from Azure Marketplace
Azure Marketplace is an online applications and services marketplace where you can browse through a wide range of enterprise applications and solutions that are certified and optimized to run on Azure, including IoT Edge modules. Azure SQL Edge can be deployed to an edge device through the marketplace.
Find the Azure SQL Edge module on the Azure Marketplace.
Pick the software plan that best matches your requirements and select Create.
On the Target Devices for IoT Edge Module page, specify the following details and then select Create.
Field Description Subscription The Azure subscription under which the IoT Hub was created IoT Hub Name of the IoT Hub where the IoT Edge device is registered and then select "Deploy to a device" option IoT Edge Device Name Name of the IoT Edge device where SQL Edge would be deployed On the Set Modules on device: page, select the Azure SQL Edge module under IoT Edge Modules. The default module name is set to AzureSQLEdge.
On the Module Settings section of the Update IoT Edge Module pane, specify the desired values for the IoT Edge Module Name, Restart Policy and Desired Status.
Important
Don't change or update the Image URI settings on the module.
On the Environment Variables section of the Update IoT Edge Module pane, specify the desired values for the environment variables. For a complete list of Azure SQL Edge environment variables, see Configure using environment variables. The following default environment variables are defined for the module.
Parameter Description MSSQL_SA_PASSWORD Change the default value to specify a strong password for the SQL Edge admin account. MSSQL_LCID Change the default value to set the desired language ID to use for SQL Edge. For example, 1036 is French. MSSQL_COLLATION Change the default value to set the default collation for SQL Edge. This setting overrides the default mapping of language ID (LCID) to collation. Important
Don't change or update the
ACCEPT_EULA
environment variable for the module.On the Container Create Options section of the Update IoT Edge Module pane, update the following options as per requirement.
Host Port
Map the specified host port to port 1433 (default SQL port) in the container.
Binds and Mounts
If you need to deploy more than one SQL Edge module, ensure that you update the mounts option to create a new source and target pair for the persistent volume. For more information on mounts and volume, see Use volumes on Docker documentation.
{ "HostConfig": { "CapAdd": [ "SYS_PTRACE" ], "Binds": [ "sqlvolume:/sqlvolume" ], "PortBindings": { "1433/tcp": [ { "HostPort": "1433" } ] }, "Mounts": [ { "Type": "volume", "Source": "sqlvolume", "Target": "/var/opt/mssql" } ] }, "Env": [ "MSSQL_AGENT_ENABLED=TRUE", "ClientTransportType=AMQP_TCP_Only", "PlanId=asde-developer-on-iot-edge" ] }
Important
Don't change the
PlanId
environment variable defined in the create config setting. If this value is changed, the Azure SQL Edge container will fail to start.Warning
If you reinstall the module, remember to remove any existing bindings first, otherwise your environment variables will not be updated.
On the Update IoT Edge Module pane, select Update.
On the Set modules on device page, select Next: Routes > if you need to define routes for your deployment. Otherwise select Review + Create. For more information on configuring routes, see Deploy modules and establish routes in IoT Edge.
On the Set modules on device page, select Create.
Connect to Azure SQL Edge
The following steps use the Azure SQL Edge command-line tool, sqlcmd, inside the container to connect to Azure SQL Edge.
Note
SQL Server command line tools, including sqlcmd, aren't available inside the ARM64 version of Azure SQL Edge containers.
Use the
docker exec -it
command to start an interactive bash shell inside your running container. In the following example,AzureSQLEdge
is name specified by theName
parameter of your IoT Edge Module.sudo docker exec -it AzureSQLEdge "bash"
Once inside the container, connect locally with the sqlcmd tool. 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 "<YourNewStrong@Passw0rd>"
Tip
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 called 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 connect and run SQL queries against your Azure SQL Edge instance 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.
In this quickstart, you deployed a SQL Edge Module on an IoT Edge device.
Next steps
Povratne informacije
https://aka.ms/ContentUserFeedback.
Stiže uskoro: Tijekom 2024. postupno ćemo ukinuti servis Problemi sa servisom GitHub kao mehanizam za povratne informacije za sadržaj i zamijeniti ga novim sustavom za povratne informacije. Dodatne informacije potražite u članku:Pošaljite i pogledajte povratne informacije za