{"id":1264,"date":"2024-08-19T12:21:01","date_gmt":"2024-08-19T12:21:01","guid":{"rendered":"https:\/\/markedcode.com\/?p=1264"},"modified":"2025-03-03T13:39:43","modified_gmt":"2025-03-03T13:39:43","slug":"tier1-db-to-tier2-env","status":"publish","type":"post","link":"https:\/\/markedcode.com\/index.php\/2024\/08\/19\/tier1-db-to-tier2-env\/","title":{"rendered":"Tier1 DB to Tier2 Env"},"content":{"rendered":"\n<p>Moving a Tier1 cloud hosted DB to a Tier2 environment is not as straightforward as taking a backup of one and restoring it to another. This is because Tier1 environments use Windows SQL while Tier2 environments use Azure SQL. To facilitate this move, we need to do the following steps:<\/p>\n\n\n\n<p><strong>Take a backup of the database (.bak)<\/strong><\/p>\n\n\n\n<p>In the Tier1 VM&#8217;s SSMS, open a new query. Be sure you are running under the &#8216;master&#8217; section. Run the following query to output a .bak file of the AxDB database. This back up will save to the D drive, you may need to create the folder &#8216;Backups&#8217; here before running the query. After this is ran you can see the created .bak file here.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"295\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-10-1024x295.png\" alt=\"\" class=\"wp-image-1265\" srcset=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-10-1024x295.png 1024w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-10-300x86.png 300w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-10-768x221.png 768w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-10.png 1156w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<pre class=\"wp-block-preformatted\">BACKUP DATABASE[AxDB] TO DISK = N'D:\\Backups\\axdb_golden.bak' WITHNOFORMAT, NOINIT,\nNAME = N'AxDB_golden-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10\nGO<\/pre>\n\n\n\n<p><strong>Import this to have a local copy of the DB<\/strong><\/p>\n\n\n\n<p>In SSMS, right click the &#8216;Databases&#8217; node and select &#8216;Restore database\u2026&#8217;, then follow the wizard to select and import our previously taken database backup. Name this database accordingly, for example, here we call it AxDB_CopyForExport.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"956\" height=\"826\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-11.png\" alt=\"\" class=\"wp-image-1266\" srcset=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-11.png 956w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-11-300x259.png 300w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-11-768x664.png 768w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/figure><\/div>\n\n\n<p><strong>Run script to configure DB<\/strong><\/p>\n\n\n\n<p>After the import is complete, select the data base and run the following query:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">update sysglobalconfiguration\nset value = 'SQLAZURE'\nwhere name = 'BACKENDDB'\n \nupdate sysglobalconfiguration\nset value = 1\nwhere name = 'TEMPTABLEINAXDB'\n \ndrop schema [NT AUTHORITY\\NETWORK SERVICE]\ndrop user [NT AUTHORITY\\NETWORK SERVICE]\ndrop user axdbadmin\ndrop user axdeployuser\ndrop user axmrruntimeuser\ndrop user axretaildatasyncuser\ndrop user axretailruntimeuser<\/pre>\n\n\n\n<p><strong>Export database as bacpac file.<\/strong><\/p>\n\n\n\n<p>When this is complete, we can use the command prompt to run sqlpacakge commands.&nbsp; If you do not have SqlPackage.exe you can download it here:<\/p>\n\n\n\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/sql\/tools\/sqlpackage\/sqlpackage-download?view=sql-server-ver16\">https:\/\/learn.microsoft.com\/en-us\/sql\/tools\/sqlpackage\/sqlpackage-download?view=sql-server-ver16<\/a><\/p>\n\n\n\n<p>This will output our database as a .bacpac file that can be applied to a tier2 environment.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Use CMD: C:\\Users\\Admin24e60794fb\\Desktop\\sqlpackage\\sqlpackage.exe \/a:export \/ssn:localhost \/sdn:AxDB_CopyForExport \/tf:D:\\Backups\\AxDBGold2.bacpac \/p:CommandTimeout=1200 \/p:VerifyFullTextDocumentTypesSupported=false \/SourceTrustServerCertificate:True<\/pre>\n\n\n\n<p><strong>Import to LCS<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now you can go to LCS &gt; Asset library &gt; Database backup\n<ul class=\"wp-block-list\">\n<li>Select your file and select the backup type as \u2018Product database (SQL Server or .bak)\u2019 and upload this file.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"242\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-12-1024x242.png\" alt=\"\" class=\"wp-image-1267\" srcset=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-12-1024x242.png 1024w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-12-300x71.png 300w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-12-768x181.png 768w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-12-1536x363.png 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>Then go to the tier 2 environment in LCS where you want to move the database too. Select Maintain &gt; Move data base.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"332\" height=\"464\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-13.png\" alt=\"\" class=\"wp-image-1268\" srcset=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-13.png 332w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-13-215x300.png 215w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/figure><\/div>\n\n\n<p>Then choose import database.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"667\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-14.png\" alt=\"\" class=\"wp-image-1269\" srcset=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-14.png 381w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-14-171x300.png 171w\" sizes=\"auto, (max-width: 381px) 100vw, 381px\" \/><\/figure><\/div>\n\n\n<p>Select our database from the asset library.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"274\" height=\"186\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-15.png\" alt=\"\" class=\"wp-image-1270\"\/><\/figure><\/div>\n\n\n<p>And wait for the import to complete!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"758\" height=\"172\" src=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-16.png\" alt=\"\" class=\"wp-image-1271\" srcset=\"https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-16.png 758w, https:\/\/markedcode.com\/wp-content\/uploads\/2024\/07\/image-16-300x68.png 300w\" sizes=\"auto, (max-width: 758px) 100vw, 758px\" \/><\/figure><\/div>\n\n\n<p>Once this is complete, you can go and enable all the users you want to have access to the system.<\/p>\n\n\n\n<p>Note: To enable users you may need to request JIT access. Then connect to the DB via SSMS and run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">update userinfo set enable = 1<\/pre>\n\n\n\n<p>Reference: <a href=\"https:\/\/axhowto.wordpress.com\/2021\/04\/09\/db-restore-from-cloud-hosted-tier-1-environment-to-tier-2-environment-in-d365fo\/\">DB Restore from cloud hosted Tier 1 environment to Tier 2 + environment in D365FO \u2013 axhowto (wordpress.com)<\/a><\/p>\n\n\n\n<p>Keep reading about D365 tips and tricks here:&nbsp; <a href=\"https:\/\/markedcode.com\/index.php\/category\/d365\/\">https:\/\/markedcode.com\/index.php\/category\/d365\/<\/a><\/p>\n\n\n\n<p>For technical questions, please visit <a href=\"https:\/\/d365techsupport.com\" data-type=\"link\" data-id=\"https:\/\/d365techsupport.com\">https:\/\/d365techsupport.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Moving a Tier1 cloud hosted DB to a Tier2 environment is not as straightforward as taking a backup of one and restoring it to another. This is because Tier1 environments use Windows SQL while Tier2 environments use Azure SQL. To facilitate this move, we need to do the following steps: Take a backup of the<\/p>\n","protected":false},"author":1,"featured_media":1274,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7,1],"tags":[6,40,39],"class_list":{"0":"post-1264","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-d365","8":"category-uncategorized","9":"tag-d365","10":"tag-db","11":"tag-ssms"},"_links":{"self":[{"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=1264"}],"version-history":[{"count":3,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1264\/revisions"}],"predecessor-version":[{"id":1325,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1264\/revisions\/1325"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/media\/1274"}],"wp:attachment":[{"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=1264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=1264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/markedcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=1264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}