Importing .bac files (like AdventureWorks sample databases) into Azure SQL Cloud Database

Jay (Vijayasimha BR)
4 min readJun 30, 2024

--

attractive indian woman wearing crop top and shorts, working on a laptop, digital paint, beautiful, indoors, well lit

Before I can do RAG for AI models, I must first learn how to import test databases into Azure Cloud SQL Servers.

Last night I was fooling around with SQL tools (Management Studio, running a local SQL Server, provisioning Azure SQL database) and so on. I realized; I want to re-familiarize myself with these tools as I will be using them in my upcoming plans to do some AI related learning with Small LLMS like Phi 3.

It occured to me, I need some cool, mature and also familiar databases to play around with. Immediately, i thought of my old friend, Adventure Works database that I use when I teach SQL in my .NET classes. So, I decided to upload a copy of that to Azure SQL. It’s not straight forward as I imagined. It was a lot of steps, and I figured, I will make a blog post about it.

So, let’s begin.

attractive indian woman wearing crop top and shorts, working on a laptop, digital paint, beautiful, indoors, well lit

Also, I am spending a lot of time with Stable Diffusion and other AI image generators lately because I think the technology of image generation is fascinating, just like conversational AI. So, please excuse the many attractive photos I have put in my blog post.

First up, you want to get the Adventure Works backup file, which is available here, in “.bac” format.

Here, the key thing to remember is the usage of .bac format, which is the source of the current challenge. You cannot just import .bac directly into Azure. It’s just not possible.

So, we first need to change this to a format that Azure does like, which is .bacpac.

For this we need a couple of things.

  1. SQL Server Management Studio (https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16)
  2. SQL Express Server. (https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-ver16)

Now, it is possible to import .bac file into the SQL Server Local Server. It looks something like this.

image 1

Here, please remember, you cannot do this import with the SQL server that is already there in Visual Studio, because it is an old version.

image 2

So, you MUST install the SQL Server Express, the newer more recent version. So, then, you will see something like this.

image 3.

and this.

image 4.

Now, you must export, from the SQL Express Local server, a .bacpac file. Essentially, I am using SQL Express as a ‘converter’ for the sake of pushing the data to Azure.

image 5.

Now, this format, is acceptable to Azure SQL Server. So, here we go.

image 6.

Now, here, look at the titles. They both say, source and destination is same. Which is weird because I set the source to local server, and destination to azure server. So, if you also get the same bizarre screen, don’t worry about it. Just ignore it.

image 7.

and you will see something like this.

image 8

Now, if you check your Management Studio, you will see that tables are identical on both local and Azure.

image 9

Now, a couple of ways to make sure it’s all good. An optional step.

image 10

Above, I am using Azure Data Studio to see if data is present.

image 11

And, also, in the Azure Portal for added precaution.

So, there you have it. Importing a .bac file into your Azure cloud Microsoft SQL DB.

Hire me at UpWork or Fiverr or codementor or GitHub. more about me on my personal profile, and also on my personal website.

--

--

No responses yet