Skip to content

Commit 279f4e0

Browse files
authored
Merge pull request #115267 from MicrosoftDocs/release-preview-sqldb-edge
Build - Azure SQL DB Edge
2 parents 70760bd + 39b622c commit 279f4e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3245
-363
lines changed

.openpublishing.redirection.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52117,6 +52117,41 @@
5211752117
"source_path": "articles/visual-studio/vs-storage-cloud-services-what-happened.md",
5211852118
"redirect_url": "/azure/storage",
5211952119
"redirect_document_id": false
52120+
},
52121+
{
52122+
"source_path": "articles/sql-database-edge/index.yml",
52123+
"redirect_url": "/azure/azure-sql-edge/",
52124+
"redirect_document_id": true
52125+
},
52126+
{
52127+
"source_path": "articles/sql-database-edge/deploy-onnx.md",
52128+
"redirect_url": "/azure/azure-sql-edge/deploy-onnx",
52129+
"redirect_document_id": true
52130+
},
52131+
{
52132+
"source_path": "articles/sql-database-edge/deploy-portal.md",
52133+
"redirect_url": "/azure/azure-sql-edge/deploy-portal",
52134+
"redirect_document_id": true
52135+
},
52136+
{
52137+
"source_path": "articles/sql-database-edge/onnx-overview.md",
52138+
"redirect_url": "/azure/azure-sql-edge/onnx-overview",
52139+
"redirect_document_id": true
52140+
},
52141+
{
52142+
"source_path": "articles/sql-database-edge/overview.md",
52143+
"redirect_url": "/azure/azure-sql-edge/overview",
52144+
"redirect_document_id": true
52145+
},
52146+
{
52147+
"source_path": "articles/sql-database-edge/stream-analytics.md",
52148+
"redirect_url": "/azure/azure-sql-edge/stream-analytics",
52149+
"redirect_document_id": true
52150+
},
52151+
{
52152+
"source_path": "articles/sql-database-edge/tutorial-sync-data-factory.md",
52153+
"redirect_url": "/azure/azure-sql-edge/tutorial-sync-data-factory",
52154+
"redirect_document_id": true
5212052155
}
5212152156
]
5212252157
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: ALTER EXTERNAL STREAM (Transact-SQL) - Azure SQL Edge (Preview)
3+
description: Learn about the ALTER EXTERNAL STREAM statement in Azure SQL Edge (Preview)
4+
keywords:
5+
services: sql-database-edge
6+
ms.service: sql-database-edge
7+
ms.topic: conceptual
8+
author: SQLSourabh
9+
ms.author: sourabha
10+
ms.reviewer: sstein
11+
ms.date: 05/19/2020
12+
---
13+
14+
# ALTER EXTERNAL STREAM (Transact-SQL)
15+
16+
Modifies the definition of an External Stream. Modifying an External Stream that is used by a streaming job in a *Running* state is not allowed.
17+
18+
19+
20+
## Syntax
21+
22+
```sql
23+
ALTER EXTERNAL STREAM external_stream_name
24+
SET
25+
[DATA_SOURCE] = <data_source_name>
26+
, LOCATION = <location_name>
27+
, EXTERNAL_FILE_FORMAT = <external_file_format_name>
28+
, INPUT_OPTIONS = <input_options>
29+
, OUTPUT_OPTIONS = <output_options>
30+
```
31+
32+
## Arguments
33+
34+
For details on the Alter External Stream command arguments, see [CREATE EXTERNAL STREAM (Transact-SQL)](create-external-stream-transact-sql.md).
35+
36+
## Return code values
37+
38+
ALTER EXTERNAL STREAM returns 0 if successful. A non-zero return value indicates failure.
39+
40+
41+
## See also
42+
43+
- [CREATE EXTERNAL STREAM (Transact-SQL)](create-external-stream-transact-sql.md)
44+
- [DROP EXTERNAL STREAM (Transact-SQL)](drop-external-stream-transact-sql.md)
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
title: Backup and restore databases - Azure SQL Edge (Preview)
3+
description: Learn about backup and restore capabilities in Azure SQL Edge (Preview)
4+
keywords:
5+
services: sql-database-edge
6+
ms.service: sql-database-edge
7+
ms.topic: conceptual
8+
author: SQLSourabh
9+
ms.author: sourabha
10+
ms.reviewer: sstein
11+
ms.date: 05/19/2020
12+
---
13+
14+
# Backup and Restore databases in Azure SQL Edge (Preview)
15+
16+
Azure SQL Edge is built on the latest versions of the Microsoft SQL Server Database Engine on Linux, providing similar backup and restore database capabilities as those available in SQL Server on Linux and SQL Server running in containers. Backup and restore component provides an essential safeguard for protecting data stored in your Azure SQL Edge databases. To minimize the risk of catastrophic data loss, it's recommended that you back up your databases periodically to preserve modifications to your data on a regular basis. A well-planned backup and restore strategy helps protect databases against data loss caused by a variety of failures. Test your strategy by restoring a set of backups and then recovering your database to prepare you to respond effectively to a disaster.
17+
18+
To read more about why backups are important, see [Back Up and Restore of SQL Server Databases](/sql/relational-databases/backup-restore/back-up-and-restore-of-sql-server-databases/).
19+
20+
Azure SQL Edge supports backup to and restore from both local storage or from Azure blobs. For more information on backup to and restore from Azure Blob Storage, refer [SQL Server Backup and Restore with Microsoft Azure Blob Storage Service](/sql/relational-databases/backup-restore/sql-server-backup-and-restore-with-microsoft-azure-blob-storage-service/) and [SQL Server Backup to URL](/sql/relational-databases/backup-restore/sql-server-backup-to-url).
21+
22+
## Backing up a database in Azure SQL Edge
23+
24+
Azure SQL Edge supports the same backup types as supported by SQL Server. For a complete list of the backup types supported in SQL Server, refer [Backup Overview](/sql/relational-databases/backup-restore/backup-overview-sql-server/).
25+
26+
> [!IMPORTANT]
27+
> Databases created in Azure SQL Edge use simple recovery model by default. As such log backups cannot be performed on these databases. If there is a need to perform log backups on these databases, an administrator would need to change the database recovery model to full recovery model. For a complete list of recovery models supported by SQL Server, refer [Recovery Model Overview](/sql/relational-databases/backup-restore/recovery-models-sql-server#RMov).
28+
29+
### Backup to local disk
30+
31+
In the example provided below, BACKUP DATABASE Transact-SQL command is used to create a database backup in the container. For the purpose of this example, a new folder called "backup" is created to store the backup files.
32+
33+
1. Create a folder for the backups. This command needs to be executed on the host where your Azure SQL Edge container is running. In the command below replace **<AzureSQLEdge_Container_Name>** with the name of Azure SQL Edge container in your deployment.
34+
35+
```bash
36+
sudo docker exec -it <AzureSQLEdge_Container_Name> mkdir /var/opt/mssql/backup
37+
```
38+
39+
2. Connect to the Azure SQL Edge instance using SQL Server Management Studio (SSMS) or using Azure Data Studio (ADS) and run the Backup database command to take the backup of your user database. In the example below, we are taking the backup of the *IronOreSilicaPrediction* database.
40+
41+
```sql
42+
BACKUP DATABASE [IronOreSilicaPrediction]
43+
TO DISK = N'/var/opt/mssql/backup/IronOrePredictDB.bak'
44+
WITH NOFORMAT, NOINIT, NAME = N'IronOreSilicaPrediction-Full Database Backup',
45+
SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
46+
GO
47+
```
48+
49+
3. After you run the command and if the backup of the database is successful, you'll see messages similar to the following in the results section of SSMS or ADS.
50+
51+
```txt
52+
10 percent processed.
53+
20 percent processed.
54+
30 percent processed.
55+
40 percent processed.
56+
50 percent processed.
57+
60 percent processed.
58+
70 percent processed.
59+
80 percent processed.
60+
90 percent processed.
61+
100 percent processed.
62+
Processed 51648 pages for database 'IronOreSilicaPrediction', file 'IronOreSilicaPrediction' on file 1.
63+
Processed 2 pages for database 'IronOreSilicaPrediction', file 'IronOreSilicaPrediction_log' on file 1.
64+
BACKUP DATABASE successfully processed 51650 pages in 3.588 seconds (112.461 MB/sec).
65+
66+
Completion time: 2020-04-09T23:54:48.4957691-07:00
67+
```
68+
69+
### Backup to URL
70+
71+
Azure SQL Edge supports backups to both page blobs and block blobs. For more information on page blobs and block blobs, refer [Backup to Block blob vs Page blob](https://docs.microsoft.com/sql/relational-databases/backup-restore/sql-server-backup-to-url?view=sql-server-ver15#blockbloborpageblob). In the example below, database *IronOreSilicaPrediction* is being backed up to a block blob.
72+
73+
1. The first step in configuring backups to block blobs is to generate a shared access signature (SAS) token that can be used to create a SQL Server Credential on Azure SQL Edge. The script creates a Shared Access Signature that is associated with a Stored Access Policy. For more information, see [Shared Access Signatures, Part 1: Understanding the SAS Model](https://azure.microsoft.com/documentation/articles/storage-dotnet-shared-access-signature-part-1/). The script also writes the T-SQL command required to create the credential on SQL Server. The script below assumes that you already have an Azure subscription with a storage account and a storage container for the backups.
74+
75+
```PowerShell
76+
# Define global variables for the script
77+
$subscriptionName='<your subscription name>' # the name of subscription name you will use
78+
$resourcegroupName = '<your resource group name>' # the name of resource group you will use
79+
$storageAccountName= '<your storage account name>' # the storage account name you will use for backups
80+
$containerName= '<your storage container name>' # the storage container name to which you will attach the SAS policy with its SAS token
81+
$policyName = 'SASPolicy' # the name of the SAS policy
82+
83+
# adds an authenticated Azure account for use in the session
84+
Login-AzAccount
85+
86+
# set the tenant, subscription and environment for use in the rest of
87+
Select-AzSubscription -Subscription $subscriptionName
88+
89+
# Generate the SAS token
90+
$sa = Get-AzStorageAccount -ResourceGroupName $resourcegroupName -Name $storageAccountName
91+
$storagekey = Get-AzStorageAccountKey -ResourceGroupName $resourcegroupName -Name $storageAccountName
92+
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storagekey[0].Value
93+
$cbc = Get-AzStorageContainer -Name $containerName -Context $storageContext
94+
$policy = New-AzStorageContainerStoredAccessPolicy -Container $containerName -Policy $policyName -Context $storageContext -ExpiryTime $(Get-Date).ToUniversalTime().AddYears(10) -Permission "rwld"
95+
$sas = New-AzStorageContainerSASToken -Policy $policyName -Context $storageContext -Container $containerName
96+
Write-Host 'Shared Access Signature= '$($sas.Substring(1))''
97+
98+
# Outputs the Transact SQL to the clipboard and to the screen to create the credential using the Shared Access Signature
99+
Write-Host 'Credential T-SQL'
100+
$tSql = "CREATE CREDENTIAL [{0}] WITH IDENTITY='Shared Access Signature', SECRET='{1}'" -f $cbc.CloudBlobContainer.Uri.AbsoluteUri,$sas.Substring(1)
101+
$tSql | clip
102+
Write-Host $tSql
103+
```
104+
105+
After successfully running the script, copy the CREATE CREDENTIAL command to a query tool, connect to an instance of SQL Server and run the command to create the credential with the Shared Access Signature.
106+
107+
2. Connect to the Azure SQL Edge instance using SQL Server Management Studio (SSMS) or using Azure Data Studio (ADS) and create the credential using the command from the previous step. Make sure to replace the CREATE CREDENTIAL command with the actual output from the previous step.
108+
109+
```sql
110+
IF NOT EXISTS
111+
(SELECT * FROM sys.credentials
112+
WHERE name = 'https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>')
113+
CREATE CREDENTIAL [https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>]
114+
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
115+
SECRET = '<SAS_TOKEN>';
116+
```
117+
118+
3. The following command takes a backup of the *IronOreSilicaPrediction* to the Azure storage container.
119+
120+
```sql
121+
BACKUP DATABASE IronOreSilicaPrediction
122+
TO URL = 'https://<mystorageaccountname>.blob.core.windows.net/<mycontainername>/IronOreSilicaPrediction.bak'
123+
With MAXTRANSFERSIZE = 4194304,BLOCKSIZE=65536;
124+
GO
125+
```
126+
127+
## Restoring a database in Azure SQL Edge
128+
129+
Azure SQL Edge supports restoring from both a local disk, a network location or from an Azure Blob Storage account. For an overview of Restore and Recovery in SQL Server, refer [Restore and Recovery Overview](https://docs.microsoft.com/sql/relational-databases/backup-restore/restore-and-recovery-overview-sql-server?view=sql-server-ver15). For an overview of the simple recovery model in SQL Server, refer [Complete Database Restores (Simple Recovery Model)](https://docs.microsoft.com/sql/relational-databases/backup-restore/complete-database-restores-simple-recovery-model?view=sql-server-ver15).
130+
131+
### Restore from local disk
132+
133+
This example uses the *IronOreSilicaPrediction* backup performed in the previous example for restoration as a new database with a different name.
134+
135+
1. If the database backup file is not already present in the container, you can use the command below to copy the file into the container. The example below assumes that the backup file is present on the local host and is being copied to the /var/opt/mssql/backup folder into an Azure SQL Edge container named sql1.
136+
137+
```bash
138+
sudo docker cp IronOrePredictDB.bak sql1:/var/opt/mssql/backup
139+
```
140+
141+
2. Connect to the Azure SQL Edge instance using SQL Server Management Studio (SSMS) or using Azure Data Studio (ADS) to execute the restore command. In the example below, the **IronOrePredictDB.bak** is restored to create a new database **IronOreSilicaPrediction_2**
142+
143+
```sql
144+
Restore FilelistOnly from disk = N'/var/opt/mssql/backup/IronOrePredictDB.bak'
145+
146+
Restore Database IronOreSilicaPrediction_2
147+
From disk = N'/var/opt/mssql/backup/IronOrePredictDB.bak'
148+
WITH MOVE 'IronOreSilicaPrediction' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_2.mdf',
149+
MOVE 'IronOreSilicaPrediction_log' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_2.ldf'
150+
```
151+
152+
3. After you run the restore command and if the restore operation was successful, you'll see the messages similar to the following in the output window.
153+
154+
```txt
155+
Processed 51648 pages for database 'IronOreSilicaPrediction_2', file 'IronOreSilicaPrediction' on file 1.
156+
Processed 2 pages for database 'IronOreSilicaPrediction_2', file 'IronOreSilicaPrediction_log' on file 1.
157+
RESTORE DATABASE successfully processed 51650 pages in 6.543 seconds (61.670 MB/sec).
158+
159+
Completion time: 2020-04-13T23:49:21.1600986-07:00
160+
```
161+
162+
### Restore from URL
163+
164+
Azure SQL Edge also supports restoring a database from an Azure Storage account. Restores can be performed from either the block blobs or page blob backups. In the example provided below, the *IronOreSilicaPrediction_2020_04_16.bak* database backup file on a block blob is restored to create the database *IronOreSilicaPrediction_3*.
165+
166+
```sql
167+
RESTORE DATABASE IronOreSilicaPrediction_3
168+
FROM URL = 'https://mystorageaccount.blob.core.windows.net/mysecondcontainer/IronOreSilicaPrediction_2020_04_16.bak'
169+
WITH MOVE 'IronOreSilicaPrediction' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_3.mdf',
170+
MOVE 'IronOreSilicaPrediction_log' TO '/var/opt/mssql/data/IronOreSilicaPrediction_Primary_3.ldf',
171+
STATS = 10;
172+
```
173+
174+

0 commit comments

Comments
 (0)