deploy db on azure from bak from sql server - sql-server

I am working on deploying an asp.net website in azure. I have a database (SQL) from my development server that I need to deploy in azure db.
But I don't find any options to using which I can dump my whole db including schema and all data, sp, etc. to azure db.
I tried to find this on google but it says that first create backup from azure db and then use it. But I need to use the db that I have on my dev sql server!
Can anyone point me in right direction on how to do this on azure?

This is the tool I use when i want to move a database from local to azure
https://sqlazuremw.codeplex.com/
Keep in mind that the azure database is not 100% compatible with sql server. You might have to modify your database before you can really move it to azure successfully. The tool above can also help a bit on that part.

Related

Login failed after moving sharded database from self-hosted to Azure Database

Is there a proper way to move a SQL Server 2016 sharded database from self-hosted to Azure Database?
I have a SQL Server 2016 sharded database that is part of the platform (Sitecore 10) I'm working with. It has a Shard Map Manager database and two Shard databases. I want to migrate the databases from self-hosted to Azure Database.
When the database is in a SQL Server Instance, it has one login mapped to the Shard Map Manger user and both Shard users. Everything works great. Since Azure Database does not use logins the same way and the databases are partially contained, I created separate users in each database in Azure with the same name and password.
Next, I migrated the schema with Azure Data Migration Services and then the data. There are some stored procedures that Sitecore provides to setup permissions and I ran those.
Finally, I updated the ServerName and DatabaseName fields in the [__ShardManagement].[ShardsGlobal] table for the ShardMapManager DB and the [__ShardManagement].[ShardsLocal] table in both Shard databases to match the new server and database names.
When I updated the app to use the new database, it spewed errors into the log, ultimately tracking to a failed login for the user. There are 13 other databases for the app which were also migrated and work fine, only the sharded database does not work in the app. I ran a PowerShell script that tests the connection string for all of the databases. All of the connection strings were successful. Backing out only the connection strings for the sharded database fixes the errors proving that the connection to the sharded databases is the problem.
What did I do wrong and what should I do to fix it?
If the requirement is only to migrate the databases from local to Azure, the best possible way is to use SQL Server Management Studio (SSMS).
The advantage is that you can mention the new database name on Azure while migrating itself and hence no need to change later. But just make sure same named database shouldn't available already in Azure SQL Server.
You can follow the migration steps from my this answer.
Also, my suggestion is to go through the official documents Assessment rules for SQL Server to Azure SQL Database migration, Troubleshoot connecting to the SQL Server Database Engine. I'm sure you will find the useful insights there which could help to make migrated database work properly with the apps.

Azure SQL Server restore using .bak file

I have created a SQL Server in Azure and have downloaded the Azure Data Studio. I have a SQL Server database backup file (.bak) and connected to the sever that I created from Azure Data Studio and I am not seeing an option to restore the database.
I just have the back up file available and don't have any on perm database available and I want to directly restore the database to the Azure SQL Server.
Azure SQL database currently does not support this feature. The only way to restore a SQL database in Azure is to import from a BACPAC file as #Larnu said. You can follow this guide to use a BACPAC file to migrate to an Azure SQL database.
Another option:
If you get an account to connect to the local server.You can use SQL Management Studio to migrate it directly to Azure.
You can use the Azure Data Migration Assistant to perform an assessment and migrate to Azure SQL from a local database.
While both replies before mine are correct I want to add something.
You have 3 ways to migrate with a right click:
SSMS: Task > Deploy Database to SQL Azure , which will create a BACPAK file, not a .bak file.
DMA: Assess and migrate
Azure Data Studio: I discovered in this video at minute 00:35 that you can actually use Azure Data Studio with some preview functionality that will help you migrate. I haven't found any plugin and in the video there is a Microsoft e-mail so I asked to try the preview. I don't expect to be better than DMA which is the go-to tool for migration.
EDIT: I sent an e-mail to Microsoft which replied to me
"Hi Francesco,
Thanks for reaching out. We are currently in private preview in East US2 region. Will that work for you ? We will soon be expanding to other regions, so please stay tuned."
So one day migration through Azure Data Studio will be possible but for now it's only to East US2 region

Best possible ways to move the data from On-prem SQL Server to Cloud SQL instance with very minimal downtime

I have a requirement to move around 30 DB's from On-prem SQL Server to google Cloud SQL instance with very minimal downtime.
I thought of doing Logshipping/High avaialbility but Gcloud SQL is not supporting sysadmin role to add secondary instance in On-prem SQL Server.
Please let me know if there are any other ways to do this
The easiest way to do this is with a backup and a restore, but you're going to have downtime in that regard. Quite a lot of it really.
The one way you can do this is through replication. No other facility is likely to help you move to Google Cloud SQL without downtime. Here's an example of how to set it up.
This document applies exactly to your case and it's the best way to do it, basically the steps are:
Enable the Cloud Storage and Cloud SQL APIs
Create the SQL instance and Cloud Storage bucket (where you will deposit the backup created from your On-prem DB)
Create a backup from your On-prem DB, this steps depends on your version but I think that the step detailed gives you and idea, and then upload it into the just created bucket
Import the backup created into Google Cloud SQL from your Storage bucket
The last step performed in the guide is just to validate recent imported data by connecting to the instance and execute a query.
For SQL Server 2017 this is the exact same guide but for that specific version.

Copying SQL Server Transaction Logs from Local Server to Azure

I've Googled this a lot and can't really find anything. The SQL Server for our main system is on-premise, not in the cloud. I figured out how to copy our nightly SQL Server backup to Azure. I also want to copy the Transaction Logs each time they roll so if our server dies we have the transaction logs, can restore to that point and only lose at most five minutes of work, not potentially a full day.
I'm really new to Azure, just starting to learn it. Is there an easy way to copy the logs to Azure? Can it be done within SSMS? Does someone already have a script they'd be willing to share? Thanks for any tips you might have!
Yes, there is SQL Server Backup to Azure Tool
Microsoft SQL Server Backup to Microsoft Azure Tool enables backup to
Azure Blob Storage and encrypts and compresses SQL Server backups
stored locally or in the cloud.
There's also Powershell option:
Use PowerShell to Backup Multiple Databases to Windows Azure Blob Storage Service
This topic provides sample scripts that can be used to automate backups to Windows Azure Blob storage service using PowerShell cmdlets. PowerShell support for Backup and Restore to Windows Azure Blob Storage service is introduced in SQL Server 2012 SP1 CU4.
The parent article gives you TSQL options as well.

Creating a SQL Server Database on the local Azure emulator (Not online)

I have succeeded in creating a basic tables running on the azure emulator in Visual Studio 2012 and I have also managed to create a couple of SQL Server databases that work with applications on a single computer. I was wondering how you would combine these to create a SQL Server database running on my local azure emulator ,that allows other computers and mobile devices to connect to it.
I have done a bit of research on this and there are quite a few topics about it, but it seems like you have to create the database on the Azure online portal and then connect to it, but I was hoping to skip this since I want to avoid connecting to any online resources.
If someone could just please point me in the right direction , because I'm still pretty unsure about using azure and all it's features. It would be great if I could create a SQL Server database on visual studio and then just specify a connection string to it through azure. (Must connect through Azure)
"For local testing, you can use a local SQL Server (full, express or even CE) within your app - just use local connection string's in place of the SQL Azure ones in your .cscfg or .config files - then the local compute instance will connect just like any other local process would." Quoted from How do I test locally against SQL Azure?
I have read that question post, but the answer was a bit too vague for rooky programming knowledge.
I think it might be able to help me if someone could also maybe elaborate on it.
Thanks in advance !
there is no emulator for Azure SQL Database.
As the post you referenced pointed out, you use a local SQL instance (CE, server, express, localdb) to simulate your database operations.
when you're ready to move to Azure SQL Database, you just change your connection string to point to your Azure SQL Database instead of your local database.
please take note though that Azure SQL Database and your typical SQL installation have feature differences, so that into account. you may be able to run some T/SQL on your local instance that is not supported in Azure SQL

Resources