You can make backups of SQL Server by using either of the following options:
-- Example of how to make a full database backup to a URL BACKUP DATABASE [SampleDB] TO URL = 'https://<mystorageaccountname>.blob.core.windows.net/<containername>/<databasefolder>/SampleDB_full.bak' WITH INIT, COMPRESSION, CHECKSUM GO
-- Example of how to make a transactional log backup to a URL BACKUP LOG [SampleDB] TO URL = 'https://<mystorageaccountname>.blob.core.windows.net/<containername>/<databasefolder>/SampleDB_log.trn' WITH COMPRESSION, CHECKSUM
Here our database is
Azure Blob Storage is used as intermediary storage for backup files between SQL Server and SQL Managed Instance. You need to generate an SAS authentication token, with only list and read permissions, for LRS. The token will enable LRS to access Blob Storage and use the backup files to restore them on SQL Managed Instance.
Follow these steps to generate the token:
1. Open Storage Explorer from the Azure portal.
2. Expand Blob Containers.
3. Right-click the blob container and select Get Shared Access Signature.
4. Select the timeframe for token expiration. Ensure that the token is valid for the duration of your migration.
5. Select the time zone for the token: UTC or your local time.
Important:The time zone of the token and your managed instance might mismatch. Ensure that the SAS token has the appropriate time validity, taking time zones into consideration. If possible, set the time zone to an earlier and later time of your planned migration window.
6. Select the time zone for the token: UTC or your local time.
7. Select Read and List permissions only.
Important:Don’t select any other permissions. If you do, LRS won’t start. This security requirement is by design.
8. Select Create.
Before you use the SAS token to start LRS, you need to understand its structure. The URI of the generated SAS token consists of two parts separated with a question mark (
?), as shown in this example:
In our example it will be
Copy the parameters as follows:
Note: Don’t include the question mark when you copy either part of the token.
Use the following PowerShell cmdlet to log in to Azure:
Select the appropriate subscription where your managed instance resides by using the following PowerShell cmdlet:
Select-AzSubscription -SubscriptionId <subscription ID>
Disclaimer: The views expressed and the content shared are those of the author and do not reflect the views of the author's employer or techbeatly platform.