1
votes

Is it possible to somehow create an azure function which will restore an azure sql database whenever a new bacpac/bak file is created in the blob storage?

1
this looks similar: stackoverflow.com/questions/23464034/…, probably if you create a blob trigger and use the DacServices.ImportBacpac() it should work.hujtomi
you can also use the Azure REST api: docs.microsoft.com/en-us/rest/api/sql/…hujtomi
Thanks, guys. Looks like the first solution with DacServices works!Arsen Aghajanyan
@TamásHuj please consider posting this as an answer so people can upvote/mark as verified.SamaraSoucy
@SamaraSoucy-MSFT ok, I did it, thanks.hujtomi

1 Answers

1
votes

You can create an azure function with a blob trigger and in your C# code you can us the DacServices.ImportBacpac method. Here is a similar question: converting a blob (.bacpac) to .bacpac file to import database to SQL Server Azure?

And here is the MS docs: https://docs.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.dac.dacservices.importbacpac?view=sql-dacfx-140.3881.1

As an alternative solution you can also make an Azure REST API call. https://docs.microsoft.com/en-us/rest/api/sql/databases%20-%20import%20export/createimportoperation "Creates an import operation that imports a bacpac into an existing database. The existing database must be empty."