Home > Back-end >  How to open Azure database .bacpac locally for local Umbraco website?
How to open Azure database .bacpac locally for local Umbraco website?

Time:01-23

I exported and downloaded my database from Azure as a .bacpac file.

I want to install Umbraco locally and use this database locally.

How do I do it?

Every time when I open the Microsoft SQL Server Management Studio it tries to connect to the database on Azure: enter image description here

Then when I put the password it will connect to the database on Azure: enter image description here

But I want to work on the local .bacpac file.

My questions are:

How do I connect on the Microsoft SQL Server Management Studio to the local .bacpac file ?

How do I connect in the Web.config to the local database ? What should I put in the connectionString?

<connectionStrings>
    <remove name="umbracoDbDSN" />
    <add name="umbracoDbDSN" connectionString="Server=tcp:xxxxx.database.windows.net,1433;Data Source=xxxxx.database.windows.net;Initial Catalog=xxxx;Persist Security Info=False;User ID=xxxx;Password=xxxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=3600;" providerName="System.Data.SqlClient" />
</connectionStrings>

So basically I want to open and work on the local .bacpac and not on the one on the server, and only after I finish the work to deploy it back.

How do I do it?

Thanks

CodePudding user response:

The .bacpac file is essentially a backup of another database, so you can't "open" or "connect" to it directly. You need to restore it on your local database server. Which, by the way, you might not have installed as it isn't part of Management Studio. When you open Management Studio you can just click Cancel on the Connect dialog that has your Azure server in it, and then maybe follow one of the many guides available via Google ;-) Like this one, maybe: enter image description here

  • Select Import Data-tier Application.

enter image description here

  • Select your .bacpac file.

enter image description here

  • Give a name to your new database and hit finish.

enter image description here

enter image description here

  • Create a new login or choose one of the existing ones and set the user mappings as follows so that you can connect to your new Umbraco db using this user's credentials.

enter image description here

enter image description here

  • And here is how you can connect to your local db from your local Umbraco website:

    <add name="umbracoDbDSN" connectionString="server=localhost;database=YourNewUmbracoDbName;user id=youruser;password=yourpassword" providerName="System.Data.SqlClient" />
    
  • Related