{"id":144,"date":"2017-12-11T09:00:44","date_gmt":"2017-12-11T14:00:44","guid":{"rendered":"https:\/\/www.sqlskills.com\/blogs\/tim\/?p=144"},"modified":"2017-12-17T13:56:42","modified_gmt":"2017-12-17T18:56:42","slug":"sqlskills-sql101-using-backup-to-url-for-azure-vm-migrations","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/tim\/sqlskills-sql101-using-backup-to-url-for-azure-vm-migrations\/","title":{"rendered":"SQLskills SQL101: Using Backup to URL for Azure VM Migrations"},"content":{"rendered":"<p>Beginning with SQL Server 2012 SP1 CU2, we\u2019ve been able to backup SQL Server directly to the Windows Azure Blob service. This makes migrations to Azure virtual machines much easier for getting databases staged as well as actual migrations. I&#8217;ve used this method numerous times with client migrations due to its simplicity and ease of use.<\/p>\n<p>In order to use backup to URL, you\u2019ll need a few things. An active Azure subscription, a Windows Storage account, and its access key.<\/p>\n<p>To get started, first log into your Azure account and click on Storage accounts. Next you will need to click add to create a new storage account.<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image1.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-medium wp-image-145\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image1-300x56.jpg\" alt=\"image1\" width=\"300\" height=\"56\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image1-300x56.jpg 300w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image1.jpg 453w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>You\u2019ll need to provide a name for your account, select the deployment model, the kind of account, your performance level, any replication options, select to enable secure transfer or not, select which subscription to use if you have more than one, which resource group to use, your location, and whether to configure a virtual network or not. For this exercise, I am naming my account myblogdemo (all lowercase) and choosing an existing resource group, and selected East US, the rest of the settings I am taking the defaults.<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image2.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-146\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image2-125x300.jpg\" alt=\"image2\" width=\"125\" height=\"300\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image2-125x300.jpg 125w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image2.jpg 311w\" sizes=\"(max-width: 125px) 100vw, 125px\" \/><\/a><\/p>\n<p>Next you need to create a container and add some storage. Under storage accounts, click on the newly created account, for my demo, that would be myblogdemo. Next under blob service, click on containers. You\u2019ll get a message stating \u201cYou don\u2019t have any containers yet. Click \u2018+ Container\u2019 to get started.\u201d. This is toward the top of the screen. Click the + Container to add a container. You\u2019ll need to provide a name for the container as well as select the type of public access level. I like to set my containers to Private (no anonymous access) so that the container and blob data can be read by the Windows Azure account. I\u2019m going to name my container blogdemo.<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image3.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-147\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image3-300x167.jpg\" alt=\"image3\" width=\"300\" height=\"167\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image3-300x167.jpg 300w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image3.jpg 511w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>You should now see the container you just created. In my demo, I see blogdemo. Click on your container and then container properties.<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image4.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-148\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image4-300x43.jpg\" alt=\"image4\" width=\"300\" height=\"43\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image4-300x43.jpg 300w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image4.jpg 543w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>To the right of the screen you will see the properties displayed. Under URL you will see the URL you will need to provide when using backup to URL. It will be similar to https:\/\/myblogdemo.blob.core.windows.net\/blogdemo.<\/p>\n<p>Next you need to create a credential on your SQL Server instance, this is located under Security. To create a credential, right click on Credentials and select New Credential. You can specify any name that you would like, your identity is your storage account name, and your password you will find in the Access keys for your storage account. You have two keys, you can select either one, simply copy and paste the value as your password and confirm and then click OK.<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image5.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-149\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image5-175x300.jpg\" alt=\"image5\" width=\"175\" height=\"300\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image5-175x300.jpg 175w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image5.jpg 209w\" sizes=\"(max-width: 175px) 100vw, 175px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image6.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-150\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image6-300x74.jpg\" alt=\"image6\" width=\"300\" height=\"74\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image6-300x74.jpg 300w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image6.jpg 484w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now you should have a storage account, container, and a credential on your local SQL Server. You can now utilize the backup to URL feature and backup to the Windows Azure Storage service. You can demo this by backing up a database. If this is just a test and you are using a production database, I recommend using WITH COPY_ONLY so that you don\u2019t potentially mess up a restore chain.<\/p>\n<p>Your syntax would be similar to this:<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image7.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-151\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image7-300x24.jpg\" alt=\"image7\" width=\"300\" height=\"24\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image7-300x24.jpg 300w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image7-900x72.jpg 900w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image7.jpg 915w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>When I executed the above query, it took approx. 3 minutes and 58 seconds to backup the 351MB database which was 108MB compressed.<\/p>\n<p>To restore this database, you just have to create a credential on your SQL Server instance on your Azure virtual machine and your syntax would be similar to:<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image8.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-152\" src=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image8-300x23.jpg\" alt=\"image8\" width=\"300\" height=\"23\" srcset=\"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image8-300x23.jpg 300w, https:\/\/www.sqlskills.com\/blogs\/tim\/wp-content\/uploads\/2017\/12\/image8.jpg 874w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Leveraging backup to URL makes migrating to Azure virtual machines easy. You can stage a full restore and then just restore the needed logs during cut-over. Although there are a number of different ways to migrate to Azure, leveraging this method gives you much needed control and as you&#8217;ve just learned, it is very easy to setup and configure.<\/p>\n<p>I hope you found this post helpful! And, if you want to find all of our\u00a0<strong>SQLskills SQL101<\/strong>\u00a0blog posts \u2013 check out:\u00a0<a href=\"http:\/\/www.sqlskills.com\/help\/SQL101\" target=\"_blank\">SQLskills.com\/help\/SQL101<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Beginning with SQL Server 2012 SP1 CU2, we\u2019ve been able to backup SQL Server directly to the Windows Azure Blob service. This makes migrations to Azure virtual machines much easier for getting databases staged as well as actual migrations. I&#8217;ve used this method numerous times with client migrations due to its simplicity and ease of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,6,33],"tags":[58,54,57,10,56],"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/posts\/144"}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/tim\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}