1
votes

I had the Azure SQL Database backup file in azure file share or blob. I want to restore the same database from file share using PowerShell script.

So, can anyone suggest me how to write the PowerShell script for restoring the Azure SQL Database from Azure File share.

1
Does this link helps or not?Joy Wang-MSFT
Thanks @JoyWang, first I will try then I will update you if I am facing any issue.Pradeep

1 Answers

0
votes

Azure provides our an example about loading backup files from Azure Blob storage into Azure SQL Database. You can try to use this script:

CREATE DATABASE SCOPED CREDENTIAL MyAzureBlobStorageCredential 
 WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
 SECRET = '******srt=sco&sp=rwac&se=2017-02-01T00:55:34Z&st=2016-12-29T16:55:34Z***************';
 
 -- NOTE: Make sure that you don't have a leading ? in SAS token, and
 -- that you have at least read permission on the object that should be loaded srt=o&sp=r, and
 -- that expiration period is valid (all dates are in UTC time)

CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
WITH (  TYPE = BLOB_STORAGE, 
        LOCATION = 'https://****************.blob.core.windows.net/invoices', 
        CREDENTIAL= MyAzureBlobStorageCredential    --> CREDENTIAL is not required if a blob has public access!
);

BULK INSERT Sales.Invoices
FROM 'inv-2017-12-08.csv'
WITH (DATA_SOURCE = 'MyAzureBlobStorage'); 

Reference:Loading files from Azure Blob storage into Azure SQL Database

Hope this can helps you.