Apply local DB changes to Azure SQL Database - azure

I have a backup file that came from Server A and I copied that .bak files into my local and setup that DB into my Sql Server Management Studio. Now After setting it up I deployed it in Azure Sql Database. But now there were change in the Data in Server A because it's still being used, so I need to get all those changes to the Azure SQL Database that I just deployed. How am I going to do that?
Note: I'm using Azure for my server and I have a local copy of Server A database. So basically in terms of data and structure my local and the previous Server A db is the same. But after a few days Server A data is now updated and my local DB is still the same as when I just backup the db in Server A.
How can I update the DB in Azure to take all the changes in Server A and deploy it in Azure?

You've got a few choices. It's just about migrating data. It's also a question of which data you're going to migrate. Let's say it's a neat, complete replacement. Then, I'd suggest looking at the bacpac mechanism. That's a way to export a database, it's structure and data, then import it into a new location. This is one mechanism of moving to Azure.
If you can't simply replace everything, you need to look at other options. First, there's SSIS. You can build a pipeline to move the data you need. There's also export and import through sqlcmd, which can connect to Azure SQL Database. You can also look to a third party tool like Redgate SQL Data Compare as a way to pick and choose the data that gets moved. There are a whole bunch of other possible Extract/Transform/Load (ETL) tools out there that can help.

Do you want to sync schema changes as well as Data change or just Data? If it is just Data then the best service to be used would be Azure Data Migration Service, where this service can help you copy the delta with respect to Data to Azure incrementally, both is online and offline manner and you can also decide on the schedule.

Related

Challenges with Azure SQL Managed Instance

Unable to make a copy of the database using the following SQL command or through the Azure portal
CREATE DATABASE mydatabase_copy AS COPY OF mydatabase;
Unable to make a copy of the database on Azure SQL Server, no wizard is present
we know there is a way of creating bacpac and restoring it, but this is a complete manual process and take too much time
we need some automated way to achieve this.
CREATE DATABASE ... AS COPY OF is not available in Managed Instance, only in SQL Database. Instead use Point-in-time restore
Use point-in-time restore (PITR) to create a database as a copy of
another database from some time in the past. This article describes
how to do a point-in-time restore of a database in Azure SQL Managed
Instance.
Point-in-time restore is useful in recovery scenarios, such as
incidents caused by errors, incorrectly loaded data, or deletion of
crucial data. You can also use it simply for testing or auditing.
Backup files are kept for 7 to 35 days, depending on your database
settings.
Which you can automate with PowerShell.

What is the best way to automate creating SQL .bak or .bacpac backup files and saving them to an Azure cloud storage container?

Currently I am tasked with researching a solution to easily copying data from one environment to another (QA to DEV for example) as well as having the flexibility of going to different times to compare our data. It is an easy task to do locally with SSMS and I am looking for the best ways to do it using Azure and it's tools.
These are the options that I found so far:
Backup Service and Backup Vault (The MS solution that I am not asking for. They don't generate .bak files)
Azure Function to execute generate and transfer SQL (flexible but the code needs to be maintained + manage authentication)
Powershell process with Azure Automate (Flexible too but needs to be maintained)
Datafactory/SSIS (Still learning and researching)
Anyone got any tools/methods that are worth looking into before I dive deeper with a solution?
For Azure SQL database, SQL Data Sync is one of feature for the data sync between Azure SQL and SQL server(on-premise). Some limits are that Azure SQL database must be hub and each must have a primary key. That may not suit you.
Per my experience, Data Factory is the best one for you. You can copy the data between different environment, in Sink settings, we can using upsert(insert or update) operation to sync the data.
If you only want to schedule the backup automatically for the SQL, the third-part tool also could feed your request: SQL Backup and FTP.
Since you have searched a lot and found almost all the options in Azure, all the ways can achieve that. You need to know your real request, data sync or auto backup create the .bacpac file to storage. That's not a good question to help you find the best way. The way you like, the way is the best.
I went with writing an Azure Automate powershell script. including cmdlts like New-AzureRmSqlDatabaseExport and passing in the parameters was ticky but it finally did the job.

Migrate SQL Server database from Azure to AWS

I need to migrate a SQL Server database from Azure to AWS. I've tried to create a backup on Azure but it seems that option is not available, not even through a script.
I don't know if exists an option to backup in Azure, as you said. However, you can export your database to a .BACPAC file and import it in a local instance of SQL Server. Then you can create a .bak file from this database to export to the AWS.
To export your database to a bacpac file, you can follow this documentation:
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-export
You have at least a few options here:
You can indeed create a backup in Azure. The backup file will get stored in a Storage account you set up. You can then download this and transfer it to your AWS VM (or RDS services) and restore it. I believe the manual backup you create in Azure is in the form of a .BACPAC file, which is just a compressed backup file.
You can create an empty database in AWS, sync the two schemas using something like RedGate or SSDT (which is free) and then use SSIS to move the data over. Or you could use scripts if you wanted. This would be a better option if you wanted to move your data over piecemeal.
You can use features in SSMS to copy the database directly from Azure and directly to AWS. Personally though I've never had a great deal of luck moving databases like this.

Best practice to upgrade a SQL Azure DB?

I am trying to upgrade an Azure DB in a continuous release scenario. The DB lives in SQL Azure and its size keeps growing. Now it's about > 50G. In my previous on-premise experience, I usually backup the old DB in a compressed format and save it to an on-premise file sever. In case the upgrade fail, I can restore it safely.
But with SQL Azure, I am not sure if it's OK to download such a big DB from SQL Azure. And is there any best practice for the SQL Azure DB upgrade scenario?
ADD
I found this link regarding different SQL Azure backup strategies. But it'll be great if someone can share some field experiences.
Azure now has automatic exports (aka full backups) to blob storage that you can schedule. The .bacpac files are complete compressed copies of your database and blob storage is pretty cheap. To give you an idea of size we have a 20GB database that is backed up to only 500 MB. We typically keep 14 days of backups but how long to retain them is up to your needs.
It's kind of like the Ron Popeil Rotisserie. You just set it, and forget it.
Obviously after you take a backup you want to restore it somewhere else to verify it worked. It's also a good idea to periodically restore your backups to make sure they working over time. You can do all of this in the Azure Portal. Just create a new database based on a .bacpac file that you created from the automated export.
You actually don't have to download the DB on premise unless you want another copy locally. Because if you are using geo-redundant blob storage its already copied to another region and you have 6 copies in total. But again its up to you.
When you log into the management portal navigate to the Sql Database tab. Click on your DB and then click configure. There you can set up automated backups for your db to blob storage.
The path on the management portal looks like this:
https://manage.windowsazure.com/mycompany.com#Workspaces/SqlAzureExtension/SqlServer/coolazuredb/Database/5.coolazuredb/Config
Here is a screenshot of the automated export section:

How to migrate db from SQL server to SQL Azure which contains asp.net membership provider with data

In one of my project i have used Asp.net membership provider and there is some data on production environment.Now i need to to migrate that DB with SQL Azure.
I have used SQLAzureMW tool to migrate that and that tool has done proper migration except aspnet_user table's data and some of SPs and i have skip that table manually at time of final step on that tool
When i have looked in to data then aspnet_users table's data missing!
I have also read about New script for SQL Azure but i think that is for to create from scratch, i also heard about Universal Provider but confused in that.
As per my requirement what steps i need to follow to migrate existing sql db to windows azure sql db(WASD) with data and considering this what would be impact of that on application?
Note: Session State is also being managed using SQL provider here
Update
Again i have tried it with SQLAzureMW tool and this time i noticed that due to default collation type some of Sps were missing so i have run that manually as per this link
However still i need to make sure would there be any issue regarding session state Or other thing as i have migrate it's from existing db to WASD?
the SQLAzureMW tool show any message that you skip?
I have had many problems with this tool, but finally I could did everything with it. I would try creating first time Data Schema Only, and after copying the Data. Maybe you should use also DROP and CREATE option when generating the script, if the old data can't be overwrite. I hope this helps!

Resources