├── .gitignore ├── AzureSQLDB ├── assessment │ ├── ADS │ │ └── azuresqldb-assessment-sku-using-ads.md │ ├── CLI │ │ └── azuresqldb-assessment-sku-using-cli.md │ └── PowerShell │ │ └── azuresqldb-assessment-sku-using-ps.md ├── deploy │ ├── README.md │ ├── arm │ │ └── template-latest.json │ ├── bicep │ │ └── template-latest.bicep │ └── terraform │ │ ├── .gitignore │ │ ├── template-latest.tf │ │ ├── terraform.tfvars │ │ └── variables.tf └── migration │ ├── CLI │ └── azuresqldb-offline-migration-using-cli.md │ └── PowerShell │ └── azuresqldb-offline-migration-using-ps.md ├── AzureSQLMI ├── assessment │ ├── ADS │ │ └── azuresqlmi-assessment-sku-using-ads.md │ ├── CLI │ │ └── azuresqlmi-assessment-sku-using-cli.md │ └── PowerShell │ │ └── azuresqlmi-assessment-sku-using-ps.md ├── deploy │ ├── README.md │ ├── arm │ │ └── template-latest.json │ ├── bicep │ │ └── template-latest.bicep │ └── terraform │ │ ├── .gitignore │ │ ├── template-latest.tf │ │ ├── terraform.tfvars │ │ └── variables.tf └── migration │ ├── CLI │ ├── azuresqlmi-login-migration-using-cli.md │ ├── azuresqlmi-offline-migration-using-azure-storage-cli.md │ ├── azuresqlmi-offline-migration-using-file-share-cli.md │ ├── azuresqlmi-online-migration-using-azure-storage-cli.md │ └── azuresqlmi-online-migration-using-file-share-cli.md │ └── PowerShell │ ├── azuresqlmi-login-migration-using-ps.md │ ├── azuresqlmi-offline-migration-using-azure-storage-ps.md │ ├── azuresqlmi-offline-migration-using-file-share-ps.md │ ├── azuresqlmi-online-migration-using-azure-storage-ps.md │ └── azuresqlmi-online-migration-using-file-share-ps.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── SUPPORT.md ├── index.md ├── media ├── ADS │ ├── ads-assessment-install-extension.png │ ├── ads-sqldb-assessment-connect-sql.png │ ├── ads-sqldb-assessment-migration-extension-home.png │ ├── ads-sqldb-assessment-select-databases.png │ ├── ads-sqldb-assessment-sku-recommendation-view-details.png │ ├── ads-sqldb-assessment-sku-recommendation.png │ ├── ads-sqldb-assessment-summary.png │ ├── ads-sqldb-assessment-target-platform.png │ ├── ads-sqlmi-assessment-connect-sql.png │ ├── ads-sqlmi-assessment-migration-extension-home.png │ ├── ads-sqlmi-assessment-select-databases.png │ ├── ads-sqlmi-assessment-sku-recommendation-view-details.png │ ├── ads-sqlmi-assessment-sku-recommendation.png │ ├── ads-sqlmi-assessment-summary.png │ └── ads-sqlmi-assessment-target-platform.png ├── ARM-Deployment.svg ├── Azure-DevOps.svg ├── Bicep-Logo.svg ├── Terraform-Logo.svg ├── sqldb-migration-succeeded.png ├── sqldb-resource-visualizer.png ├── sqldb-sku-recommendation-cli.png ├── sqldb-sku-recommendation-html.png ├── sqldb-sku-recommendation-ps.png ├── sqlmi-connectionstring.png ├── sqlmi-login-migration-cli.png ├── sqlmi-resource-visualizer.png ├── sqlmi-sku-recommendation-cli.png ├── sqlmi-sku-recommendation-html.png └── sqlmi-sku-recommendation-ps.png └── script ├── JumpBoxPostInstallation.ps1 └── SQLVMPostInstallation.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | bld/ 27 | [Bb]in/ 28 | [Oo]bj/ 29 | [Ll]og/ 30 | [Ll]ogs/ 31 | 32 | # Visual Studio 2015/2017 cache/options directory 33 | .vs/ 34 | # Uncomment if you have tasks that create the project's static files in wwwroot 35 | #wwwroot/ 36 | 37 | # Visual Studio 2017 auto generated files 38 | Generated\ Files/ 39 | 40 | # MSTest test Results 41 | [Tt]est[Rr]esult*/ 42 | [Bb]uild[Ll]og.* 43 | 44 | # NUnit 45 | *.VisualState.xml 46 | TestResult.xml 47 | nunit-*.xml 48 | 49 | # Build Results of an ATL Project 50 | [Dd]ebugPS/ 51 | [Rr]eleasePS/ 52 | dlldata.c 53 | 54 | # Benchmark Results 55 | BenchmarkDotNet.Artifacts/ 56 | 57 | # .NET Core 58 | project.lock.json 59 | project.fragment.lock.json 60 | artifacts/ 61 | 62 | # StyleCop 63 | StyleCopReport.xml 64 | 65 | # Files built by Visual Studio 66 | *_i.c 67 | *_p.c 68 | *_h.h 69 | *.ilk 70 | *.meta 71 | *.obj 72 | *.iobj 73 | *.pch 74 | *.pdb 75 | *.ipdb 76 | *.pgc 77 | *.pgd 78 | *.rsp 79 | *.sbr 80 | *.tlb 81 | *.tli 82 | *.tlh 83 | *.tmp 84 | *.tmp_proj 85 | *_wpftmp.csproj 86 | *.log 87 | *.vspscc 88 | *.vssscc 89 | .builds 90 | *.pidb 91 | *.svclog 92 | *.scc 93 | 94 | # Chutzpah Test files 95 | _Chutzpah* 96 | 97 | # Visual C++ cache files 98 | ipch/ 99 | *.aps 100 | *.ncb 101 | *.opendb 102 | *.opensdf 103 | *.sdf 104 | *.cachefile 105 | *.VC.db 106 | *.VC.VC.opendb 107 | 108 | # Visual Studio profiler 109 | *.psess 110 | *.vsp 111 | *.vspx 112 | *.sap 113 | 114 | # Visual Studio Trace Files 115 | *.e2e 116 | 117 | # TFS 2012 Local Workspace 118 | $tf/ 119 | 120 | # Guidance Automation Toolkit 121 | *.gpState 122 | 123 | # ReSharper is a .NET coding add-in 124 | _ReSharper*/ 125 | *.[Rr]e[Ss]harper 126 | *.DotSettings.user 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # NuGet Symbol Packages 186 | *.snupkg 187 | # The packages folder can be ignored because of Package Restore 188 | **/[Pp]ackages/* 189 | # except build/, which is used as an MSBuild target. 190 | !**/[Pp]ackages/build/ 191 | # Uncomment if necessary however generally it will be regenerated when needed 192 | #!**/[Pp]ackages/repositories.config 193 | # NuGet v3's project.json files produces more ignorable files 194 | *.nuget.props 195 | *.nuget.targets 196 | 197 | # Microsoft Azure Build Output 198 | csx/ 199 | *.build.csdef 200 | 201 | # Microsoft Azure Emulator 202 | ecf/ 203 | rcf/ 204 | 205 | # Windows Store app package directories and files 206 | AppPackages/ 207 | BundleArtifacts/ 208 | Package.StoreAssociation.xml 209 | _pkginfo.txt 210 | *.appx 211 | *.appxbundle 212 | *.appxupload 213 | 214 | # Visual Studio cache files 215 | # files ending in .cache can be ignored 216 | *.[Cc]ache 217 | # but keep track of directories ending in .cache 218 | !?*.[Cc]ache/ 219 | 220 | # Others 221 | ClientBin/ 222 | ~$* 223 | *~ 224 | *.dbmdl 225 | *.dbproj.schemaview 226 | *.jfm 227 | *.pfx 228 | *.publishsettings 229 | orleans.codegen.cs 230 | 231 | # Including strong name files can present a security risk 232 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 233 | #*.snk 234 | 235 | # Since there are multiple workflows, uncomment next line to ignore bower_components 236 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 237 | #bower_components/ 238 | 239 | # RIA/Silverlight projects 240 | Generated_Code/ 241 | 242 | # Backup & report files from converting an old project file 243 | # to a newer Visual Studio version. Backup files are not needed, 244 | # because we have git ;-) 245 | _UpgradeReport_Files/ 246 | Backup*/ 247 | UpgradeLog*.XML 248 | UpgradeLog*.htm 249 | ServiceFabricBackup/ 250 | *.rptproj.bak 251 | 252 | # SQL Server files 253 | *.mdf 254 | *.ldf 255 | *.ndf 256 | 257 | # Business Intelligence projects 258 | *.rdl.data 259 | *.bim.layout 260 | *.bim_*.settings 261 | *.rptproj.rsuser 262 | *- [Bb]ackup.rdl 263 | *- [Bb]ackup ([0-9]).rdl 264 | *- [Bb]ackup ([0-9][0-9]).rdl 265 | 266 | # Microsoft Fakes 267 | FakesAssemblies/ 268 | 269 | # GhostDoc plugin setting file 270 | *.GhostDoc.xml 271 | 272 | # Node.js Tools for Visual Studio 273 | .ntvs_analysis.dat 274 | node_modules/ 275 | 276 | # Visual Studio 6 build log 277 | *.plg 278 | 279 | # Visual Studio 6 workspace options file 280 | *.opt 281 | 282 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 283 | *.vbw 284 | 285 | # Visual Studio LightSwitch build output 286 | **/*.HTMLClient/GeneratedArtifacts 287 | **/*.DesktopClient/GeneratedArtifacts 288 | **/*.DesktopClient/ModelManifest.xml 289 | **/*.Server/GeneratedArtifacts 290 | **/*.Server/ModelManifest.xml 291 | _Pvt_Extensions 292 | 293 | # Paket dependency manager 294 | .paket/paket.exe 295 | paket-files/ 296 | 297 | # FAKE - F# Make 298 | .fake/ 299 | 300 | # CodeRush personal settings 301 | .cr/personal 302 | 303 | # Python Tools for Visual Studio (PTVS) 304 | __pycache__/ 305 | *.pyc 306 | 307 | # Cake - Uncomment if you are using it 308 | # tools/** 309 | # !tools/packages.config 310 | 311 | # Tabs Studio 312 | *.tss 313 | 314 | # Telerik's JustMock configuration file 315 | *.jmconfig 316 | 317 | # BizTalk build output 318 | *.btp.cs 319 | *.btm.cs 320 | *.odx.cs 321 | *.xsd.cs 322 | 323 | # OpenCover UI analysis results 324 | OpenCover/ 325 | 326 | # Azure Stream Analytics local run output 327 | ASALocalRun/ 328 | 329 | # MSBuild Binary and Structured Log 330 | *.binlog 331 | 332 | # NVidia Nsight GPU debugger configuration file 333 | *.nvuser 334 | 335 | # MFractors (Xamarin productivity tool) working folder 336 | .mfractor/ 337 | 338 | # Local History for Visual Studio 339 | .localhistory/ 340 | 341 | # BeatPulse healthcheck temp database 342 | healthchecksdb 343 | 344 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 345 | MigrationBackup/ 346 | 347 | # Ionide (cross platform F# VS Code tools) working folder 348 | .ionide/ 349 | -------------------------------------------------------------------------------- /AzureSQLDB/assessment/ADS/azuresqldb-assessment-sku-using-ads.md: -------------------------------------------------------------------------------- 1 | # Assessment and SKU recommendation for Azure SQL Database using Azure Data Studio 2 | 3 | Assess your SQL Server databases for Azure SQL Database readiness or to identify any migration blockers before migrating them to Azure SQL Database. 4 | 5 | [Azure Data Studio](https://learn.microsoft.com/en-us/azure-data-studio/what-is-azure-data-studio) is a unified tooling experience for data professionals. 6 | Designed to focus on the functionality data platform developers use the most, Azure Data Studio offers additional experiences available as optional extensions. It's built for data professionals who use SQL Server and Azure databases on-premises or in multicloud environments. 7 | 8 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure SQL. 9 | 10 | ## Prerequisites 11 | 12 | - SQL Server with Windows authentication or SQL authentication access 13 | 14 | ## Getting Started 15 | 16 | > [!CAUTION] 17 | > 18 | > - **Connect to the Jump Box VM** 19 | > - VM name: **jb-migration** 20 | > - Use the credentials provided on the deploy page. 21 | 22 | ## Installing Azure SQL Migration Extension 23 | 24 | - Launch Azure Data Studio. 25 | - Navigate to the "Extensions" tab located in the right-side menu. 26 | - In the search bar, type "Azure SQL Migration" and press Enter. 27 | - Locate the "Azure SQL Migration" extension from the search results. 28 | - Click on the "Install" button next to the extension to begin the installation process. 29 | 30 | ![ads-assessment-install-extension](../../../media/ADS/ads-assessment-install-extension.png) 31 | 32 | ## Connecting to SQL Server 33 | 34 | After successfully installing the extension, follow these steps to connect to the SQL Server: 35 | 36 | - Navigate to the "Connections" tab in the top menu. 37 | - Click on "New Connection" to open the connection dialog. 38 | - In the "Server" field, enter the following: `10.0.0.4` 39 | - Choose "Windows Authentication" as the authentication type. 40 | - Set "Trust server certificate" to "True". 41 | - Click "Connect" to establish the connection to the SQL Server. 42 | 43 | ![ads-assessment-connect-sql](/media/ADS/ads-sqldb-assessment-connect-sql.png) 44 | 45 | After establishing the connection, the Manage page will appear. 46 | 47 | - Go to the sidebar menu and select "General" to find the "Azure SQL Migration" extension. 48 | - Click on the "Azure SQL Migration" extension to open it and begin using its features for migration tasks. 49 | 50 | ## Exploring Azure SQL Migration Extension 51 | 52 | After accessing the home page of Azure SQL Migration, follow these steps: 53 | 54 | - Look for the "+ New migration" button and click on it. 55 | - Choose all databases that you want to include in the assessment. 56 | - Click "Next" to proceed to the next step in the migration process. 57 | 58 | ![ads-assessment-migration-extension-home](/media/ADS/ads-sqldb-assessment-migration-extension-home.png) 59 | 60 | - Click on the checkbox to select all databases available for assessment. 61 | - Alternatively, individually check the checkboxes next to each database to select them manually. 62 | - Once all databases are selected, proceed to the next step in the migration process. 63 | 64 | ![ads-assessment-select-databases](/media/ADS/ads-sqldb-assessment-select-databases.png) 65 | 66 | ## Performance data collection and SKU recommendation 67 | 68 | - After a few minutes, a summary will appear, allowing you to review the assessment for Azure SQL targets. 69 | - To begin collecting data from your databases to determine the best SKU, click on "Start Data Collection". This will initiate the data collection process. 70 | - Alternatively, if you have already collected data, you can import it. 71 | 72 | ![ads-assessment-summary](/media/ADS/ads-sqldb-assessment-summary.png) 73 | 74 | - You need to wait for approximately 10 minutes before you can start seeing recommendations. 75 | - After this time, you'll be able to explore the SKU recommendations. 76 | - To stop collecting data, click on "Stop Data Collection". 77 | 78 | ![ads-assessment-sku-recommendation.png](/media/ADS/ads-sqldb-assessment-sku-recommendation.png) 79 | 80 | - When you click on "View Details," you'll access a detailed report for the SKU recommended. 81 | - Additionally, you have the option to save the recommendation report. 82 | 83 | ![ads-assessment-sku-recommendation-view-details.png](/media/ADS/ads-sqldb-assessment-sku-recommendation-view-details.png) 84 | 85 | ## Reviewing the assessment 86 | 87 | After reviewing the SKU recommendation, click on the "Close" button to return to the summary page. From there, proceed by clicking "Next" to review any issues or blockers. 88 | 89 | - Select "Azure SQL Database" as the target type. 90 | - Navigate to the database named "AdventureWorks_with_issues". 91 | - Click on the findings to view detailed information about the issues. 92 | - Review issues or blockers for a specific database. 93 | 94 | ![ads-assessment-target-platform](/media/ADS/ads-sqldb-assessment-target-platform.png) 95 | 96 | You can save your assessment and review it later. 97 | 98 | ## Page Navigator 99 | 100 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 101 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 102 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 103 | -------------------------------------------------------------------------------- /AzureSQLDB/assessment/CLI/azuresqldb-assessment-sku-using-cli.md: -------------------------------------------------------------------------------- 1 | # Assessment and SKU recommendation for Azure SQL Database using CLI 2 | 3 | Assess your SQL Server databases for Azure SQL Database readiness or to identify any migration blockers before migrating them to Azure SQL Database. 4 | 5 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure SQL. 6 | 7 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 8 | 9 | ## Prerequisites 10 | 11 | - SQL Server with Windows authentication or SQL authentication access 12 | - .Net Core 3.1 (Already installed) 13 | - Azure CLI (Already installed) 14 | - Az datamigration extension 15 | 16 | ## Getting Started 17 | 18 | > [!CAUTION] 19 | > 20 | > - **Connect to the Jump Box VM** 21 | > - VM name: **jb-migration** 22 | > - Use the credentials provided on the deploy page. 23 | > 24 | 25 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 26 | 27 | 1. Install az datamigration extension. Open either a command shell or PowerShell as administrator. 28 | 29 | ```azurecli 30 | az extension add --name datamigration 31 | ``` 32 | 33 | 2. Run the following to log in from your client using your default web browser 34 | 35 | ```azurecli 36 | az login 37 | ``` 38 | 39 | If you have more than one subscription, you can select a particular subscription. 40 | 41 | ```azurecli 42 | az account set --subscription 43 | ``` 44 | 45 | ## Run the assessment 46 | 47 | 1. Run a SQL Server assessment using the ***az datamigration get-assessment*** command. 48 | 49 | ```azurecli 50 | az datamigration get-assessment ` 51 | --connection-string "Data Source=10.0.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 52 | --output-folder "C:\temp\output" ` 53 | --overwrite 54 | ``` 55 | 56 | 2. **Assessment at scale** using config file 57 | 58 | You can also create a config file to use as a parameter to run assessment on SQL servers. The config file has the following structure: 59 | 60 | ```json 61 | { 62 | "action": "Assess", 63 | "outputFolder": "C:\\temp\\output", 64 | "overwrite": "True", 65 | "sqlConnectionStrings": [ 66 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 67 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 68 | ] 69 | } 70 | ``` 71 | 72 | The config file can be passed to the cmdlet in the following way 73 | 74 | ```azurecli 75 | az datamigration get-assessment --config-file-path "C:\Users\user\document\config.json" 76 | ``` 77 | 78 | > [!NOTE] 79 | > To view the report, go to **C:\temp\output** folder and check the json file. 80 | 81 | Learn more about using [CLI to assess SQL Server](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-assessment.md) 82 | 83 | ## SKU Recommendation 84 | 85 | ### Performance data collection 86 | 87 | This step is optional. An Azure SQL DB has been already provisioned. 88 | 89 | 1. Run a SQL Server performance data collection using the ***az datamigration performance-data-collection*** command. 90 | 91 | ```azurecli 92 | az datamigration performance-data-collection ` 93 | --connection-string "Data Source=10.0.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 94 | --output-folder "C:\temp\output" ` 95 | --perf-query-interval 10 ` 96 | --number-of-iteration 5 ` 97 | --static-query-interval 120 98 | ``` 99 | 100 | > [!NOTE] 101 | > Collect as much data as you want, then stop the process. 102 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 103 | 104 | 2. Running **performance data collection at scale** using a config file 105 | 106 | You can also create a config file to use as a parameter to run performance data collection on SQL servers. 107 | The config file has the following structure: 108 | 109 | ```json 110 | { 111 | "action": "PerfDataCollection", 112 | "outputFolder": "C:\\temp\\output", 113 | "perfQueryIntervalInSec": 20, 114 | "staticQueryIntervalInSec": 120, 115 | "numberOfIterations": 7, 116 | "sqlConnectionStrings": [ 117 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 118 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 119 | ] 120 | } 121 | ``` 122 | 123 | The config file can be passed to the cmdlet in the following way. 124 | 125 | ```azurecli 126 | az datamigration performance-data-collection --config-file-path "C:\Users\user\document\config.json" 127 | ``` 128 | 129 | > [!NOTE] 130 | > Collect as much data as you want, then stop the process. 131 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 132 | 133 | Learn more about using [CLI to perform data collection](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-sku-recommendation.md) 134 | 135 | ### Get SKU Recommendation 136 | 137 | This step is optional. An Azure SQL DB has been already provisioned. 138 | 139 | 1. Get SKU recommendation using the **az datamigration get-sku-recommendation** command. 140 | 141 | ```azurecli 142 | az datamigration get-sku-recommendation ` 143 | --output-folder "C:\temp\output" ` 144 | --display-result ` 145 | --overwrite ` 146 | --target-platform "AzureSqlDatabase" 147 | ``` 148 | 149 | All results will be displayed after the command finishes. 150 | 151 | ![sku-recommendation](/media/sqldb-sku-recommendation-cli.png) 152 | 153 | 2. Get SKU recommendations at scale using a config file. 154 | 155 | You can also create a config file to use as a parameter to get SKU recommendations on SQL servers. The config file has the following structure: 156 | 157 | ```json 158 | { 159 | "action": "GetSKURecommendation", 160 | "outputFolder": "C:\\temp\\Output", 161 | "overwrite": "True", 162 | "displayResult": "True", 163 | "targetPlatform": "any", 164 | "scalingFactor": 1000 165 | } 166 | ``` 167 | 168 | Learn more about using [CLI to get SKU recommendation](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-sku-recommendation.md#get-sku-recommendation-though-console-parameters) 169 | 170 | ### View Assessment & SKU Recommendation 171 | 172 | 1. **HTML recommendations result** 173 | 174 | You can look into the output folder (C:\temp\output) to find an HTML file that also gives the details of the SKU being recommended. 175 | 176 | ![sku-recommendation-html](../../../media/sqldb-sku-recommendation-html.png) 177 | 178 | ## Page Navigator 179 | 180 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 181 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 182 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 183 | -------------------------------------------------------------------------------- /AzureSQLDB/assessment/PowerShell/azuresqldb-assessment-sku-using-ps.md: -------------------------------------------------------------------------------- 1 | # Assessment and SKU recommendation for Azure SQL Database using PowerShell 2 | 3 | Assess your SQL Server databases for Azure SQL Database readiness or to identify any migration blockers before migrating them to Azure SQL Database. 4 | 5 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure SQL. 6 | 7 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 8 | 9 | ## Prerequisites 10 | 11 | - SQL Server with Windows authentication or SQL authentication access 12 | - .Net Core 3.1 (Already installed) 13 | - Az.DataMigration PowerShell module 14 | 15 | ## Getting Started 16 | 17 | > [!CAUTION] 18 | > 19 | > - **Connect to the Jump Box VM** 20 | > - VM name: **jb-migration** 21 | > - Use the credentials provided on the deploy page. 22 | 23 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 24 | 25 | ## Run the assessment 26 | 27 | 1. Run a SQL Server assessment using the ***Get-AzDataMigrationAssessment*** command. 28 | 29 | ```powershell 30 | Get-AzDataMigrationAssessment ` 31 | -ConnectionString "Data Source=10.0.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 32 | -OutputFolder "C:\temp\output" ` 33 | -Overwrite 34 | ``` 35 | 36 | 2. **Assessment at scale** using config file 37 | 38 | You can also create a config file to use as a parameter to run assessment on SQL servers. The config file has the following structure: 39 | 40 | ```json 41 | { 42 | "action": "Assess", 43 | "outputFolder": "C:\\temp\\output", 44 | "overwrite": "True", 45 | "sqlConnectionStrings": [ 46 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 47 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 48 | ] 49 | } 50 | ``` 51 | 52 | The config file can be passed to the cmdlet in the following way 53 | 54 | ```powershell 55 | Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json" 56 | ``` 57 | 58 | > [!TIP] 59 | > 60 | > To view the report, go to **C:\temp\output** folder and check the json file. 61 | 62 | Learn more about using [PowerShell to assess SQL Server](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-assessment.md) 63 | 64 | ## SKU Recommendation 65 | 66 | ### Performance data collection 67 | 68 | This step is optional. An Azure SQL DB has been already provisioned. 69 | 70 | 1. Run a SQL Server performance data collection using the ***Get-AzDataMigrationPerformanceDataCollection*** command. 71 | 72 | ```powershell 73 | Get-AzDataMigrationPerformanceDataCollection ` 74 | -SqlConnectionStrings "Data Source=10.0.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 75 | -OutputFolder "C:\temp\output" ` 76 | -PerfQueryInterval 10 ` 77 | -NumberOfIterations 5 ` 78 | -StaticQueryInterval 120 79 | ``` 80 | 81 | > [!TIP] 82 | > 83 | > Collect as much data as you want, then stop the process. 84 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 85 | 86 | 2. Running **performance data collection at scale** using a config file 87 | 88 | You can also create a config file to use as a parameter to run performance data collection on SQL servers. 89 | The config file has the following structure: 90 | 91 | ```json 92 | { 93 | "action": "PerfDataCollection", 94 | "outputFolder": "C:\\temp\\output", 95 | "perfQueryIntervalInSec": 20, 96 | "staticQueryIntervalInSec": 120, 97 | "numberOfIterations": 7, 98 | "sqlConnectionStrings": [ 99 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 100 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 101 | ] 102 | } 103 | ``` 104 | 105 | The config file can be passed to the cmdlet in the following way. 106 | 107 | ```powershell 108 | Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath "C:\Users\user\document\config.json" 109 | ``` 110 | 111 | > [!TIP] 112 | > Collect as much data as you want, then stop the process. 113 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 114 | 115 | Learn more about using [PowerShell to perform data collection](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-sku-recommendation.md) 116 | 117 | ### Get SKU Recommendation 118 | 119 | This step is optional. An Azure SQL DB has been already provisioned. 120 | 121 | 1. Get SKU recommendation using the **az datamigration get-sku-recommendation** command. 122 | 123 | ```powershell 124 | Get-AzDataMigrationSkuRecommendation ` 125 | -OutputFolder "C:\temp\output" ` 126 | -DisplayResult ` 127 | -Overwrite ` 128 | -TargetPlatform "AzureSqlDatabase" 129 | ``` 130 | 131 | All results will be displayed after the command finishes. 132 | 133 | ![sku-recommendation](../../../media/sqldb-sku-recommendation-ps.png) 134 | 135 | 2. Get SKU recommendations at scale using a config file. 136 | 137 | You can also create a config file to use as a parameter to get SKU recommendations on SQL servers. The config file has the following structure: 138 | 139 | ```json 140 | { 141 | "action": "GetSKURecommendation", 142 | "outputFolder": "C:\\temp\\Output", 143 | "overwrite": "True", 144 | "displayResult": "True", 145 | "targetPlatform": "any", 146 | "scalingFactor": 1000 147 | } 148 | ``` 149 | 150 | Learn more about using [PowerShell to get SKU recommendation](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-sku-recommendation.md#get-sku-recommendation-though-console-parameters) 151 | 152 | ### View Assessment & SKU Recommendation 153 | 154 | 1. **HTML recommendations result** 155 | 156 | You can look into the output folder (C:\temp\output) to find an HTML file that also gives the details of the SKU being recommended. 157 | 158 | ![sku-recommendation-html](../../../media/sqldb-sku-recommendation-html.png) 159 | 160 | ## Page Navigator 161 | 162 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 163 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 164 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 165 | -------------------------------------------------------------------------------- /AzureSQLDB/deploy/README.md: -------------------------------------------------------------------------------- 1 | # Deploy the solution for Azure SQL Database 2 | 3 | In this section, you will provision all Azure resources required to complete this PoC. 4 | 5 | ## Deployment options 6 | 7 | | Deployment language | | 8 | | :-------------------------------: | :----------------------------------------------------------------------------------: | 9 | |[**ARM**](#azure-resource-manager) | [![azure resource manager](../../media/ARM-Deployment.svg)](#azure-resource-manager) | 10 | |[**Bicep**](#bicep) | [![bicep](../../media/Bicep-Logo.svg)](#bicep) | 11 | |[**Terraform**](#terraform) | [![terraform](../../media/Terraform-Logo.svg)](#terraform) | 12 | 13 | ## Deployment diagram 14 | 15 | ![resource-visualizer](/media/sqldb-resource-visualizer.png) 16 | 17 | ## Azure Resource Manager 18 | 19 | [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FSQL-Migration-AzureSQL-PoC%2Fmain%2FAzureSQLDB%2Fdeploy%2Farm%2Ftemplate-latest.json) 20 | 21 | The [ARM template (template-latest.json)](arm/template-latest.json) is used to provision Azure resources in a resource group. 22 | 23 | Right-click or `Ctrl + click` the button below to open the Azure Portal in a new window. This will redirect you to the Custom Deployment wizard in the Azure Portal. 24 | 25 | Select the Azure subscription and the resource group that you would like to use for this PoC. 26 | 27 | ## Bicep 28 | 29 | The [Bicep template (template-latest.bicep)](bicep/template-latest.bicep) is used to provision Azure resources in a resource group. 30 | 31 | [Learn more about bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview?tabs=bicep). 32 | 33 | ### Prerequisites 34 | 35 | - [Install Bicep tools](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install#azure-cli) 36 | - [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) 37 | 38 | ### How to deploy it 39 | 40 | 1. Run the following to log in from your client using your default web browser 41 | 42 | ```azurecli 43 | az login 44 | ``` 45 | 46 | If you have more than one subscription, you can select a particular subscription. 47 | 48 | ```azurecli 49 | az account set --subscription 50 | ``` 51 | 52 | 2. Find a location you want to deploy the resource group 53 | 54 | ```azurecli 55 | az account list-locations -o table 56 | ``` 57 | 58 | 3. Create a resource group 59 | 60 | ```azurecli 61 | az group create --location "" --name "" 62 | ``` 63 | 64 | The following example deploys a resource group in North Europe 65 | 66 | ```azurecli 67 | az group create --location "northeurope" --name "one-click-poc" 68 | ``` 69 | 70 | 4. Deploy a bicep template 71 | 72 | ```azurecli 73 | az deployment group create --resource-group "" --template-file C:\temp\bicep\template-latest.bicep 74 | 75 | ``` 76 | 77 | The following example deploys a bicep template 78 | 79 | ```azurecli 80 | az deployment group create --resource-group "one-click-poc" --template-file C:\temp\bicep\template-latest.bicep 81 | ``` 82 | 83 | ## Terraform 84 | 85 | The [Terraform template (terraform/template-latest.tf)](terraform/template-latest.tf) is used to provision Azure resources in a resource group. 86 | 87 | [Learn more about Terraform](https://learn.microsoft.com/en-us/azure/developer/terraform/overview). 88 | 89 | Prerequisites 90 | 91 | - [Install Terraform](https://learn.microsoft.com/en-us/azure/developer/terraform/quickstart-configure) 92 | - [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) 93 | 94 | 1. Run the following to log in from your client using your default web browser 95 | 96 | ```azurecli 97 | az login 98 | ``` 99 | 100 | If you have more than one subscription, you can select a particular subscription. 101 | 102 | ```azurecli 103 | az account set --subscription 104 | ``` 105 | 106 | 2. Find a location you want to deploy the resource group 107 | 108 | ```azurecli 109 | az account list-locations -o table 110 | ``` 111 | 112 | 3. Move to the folder [AzureSQLDB/deploy/terraform](AzureSQLDB/deploy/terraform) 113 | 114 | ```azurecli 115 | cd AzureSQLDB/deploy/terraform 116 | ``` 117 | 118 | 4. Open the file [terraform.tfvars](terraform/terraform.tfvars) and provide values for the variables `resource_group_name` and `resource_group_location` 119 | 120 | e.g: 121 | 122 | ```azurecli 123 | resource_group_name = "one-click-poc" 124 | resource_group_location = "westeurope" 125 | ``` 126 | 127 | 5. Initialize a working directory for the terraform configuration 128 | 129 | ```azurecli 130 | terraform init 131 | ``` 132 | 133 | 6. Deploy the terraform template 134 | 135 | ```azurecli 136 | terraform apply -auto-approve 137 | ``` 138 | 139 | A message asking for input of a value for the variable `suffix` will be displayed 140 | 141 | ```azurecli 142 | var.suffix 143 | Enter a value: 144 | ``` 145 | 146 | Insert a value and press Enter. 147 | 148 | ## Azure Resources 149 | 150 | The template provisions the following resources in the Azure subscription 151 | 152 | - Azure Resource Group 153 | - Azure logical SQL server 154 | - Azure SQL Database 155 | - Azure Private Link for Azure SQL Database 156 | - Private DNS zone 157 | - Azure SQL VM 158 | - Network interface for Azure SQL VM 159 | - VNet for Azure SQL VM 160 | - Public IP for Azure SQL VM 161 | - NSG for Azure SQL VM 162 | - JumpBox VM 163 | - Network interface for JumpBox VM 164 | - VNet for JumpBox VM 165 | - NSG for JumpBox VM 166 | - Public IP for JumpBox VM 167 | - Virtual network peering 168 | 169 | > [!IMPORTANT] 170 | > Please note that it takes 30 to 40 min approximately to provision all these resources in an Azure subscription. 171 | 172 | Some of the Azure services provisioned require a globally unique name and a “suffix” has been added to their names to ensure uniqueness. 173 | 174 | | Azure Service | Name | Pricing Tier | How to | 175 | |:---- |:----- | :---- |:----- | 176 | | Resource Group | one-click-PoC | | [Create a Resource Group](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal#create-resource-groups) 177 | | SQL Server on Azure VM | sqlvm-001 | Standard_D8s_v3 |[Provision SQL Server on Azure VM](https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/create-sql-vm-portal?view=azuresql) | 178 | | Azure SQL Database | sqldb-*suffix* | Basic |[Create an Azure SQL Database](https://learn.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&tabs=azure-portal)| 179 | | Azure VM | jb-migration | Standard_B4ms |[Create a Windows virtual machine](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal) | 180 | 181 | ### Credential 182 | 183 | | | Admin User Name | Password | 184 | |:---- |:----- | :---- | 185 | | SQL VM | sqladmin | My\$upp3r\$ecret | 186 | | Azure SQL Database | sqladmin | My\$upp3r\$ecret | 187 | | JumpBox VM | sqladmin | My\$upp3r\$ecret | 188 | 189 | ## Page Navigator 190 | 191 | - [SQL Server migration one-click PoC to Azure SQL](../../README.md) 192 | 193 | - [One-click PoC to Azure SQL DB](../../AzureSQLDB/deploy/README.md) 194 | - ***Assessment and SKU recommendation*** 195 | - [CLI](../../AzureSQLDB/assessment/CLI/azuresqldb-assessment-sku-using-cli.md) 196 | - [PowerShell](../../AzureSQLDB/assessment/PowerShell/azuresqldb-assessment-sku-using-ps.md) 197 | - ***Offline migration*** 198 | - [CLI](../../AzureSQLDB/migration/CLI/azuresqldb-offline-migration-using-cli.md) 199 | - [PowerShell](../../AzureSQLDB/migration/PowerShell/azuresqldb-offline-migration-using-ps.md) 200 | 201 | - [One-click PoC to Azure SQL MI](../../AzureSQLMI/deploy/README.md) 202 | - ***Assessment and SKU recommendation*** 203 | - [CLI](../../AzureSQLMI/assessment/CLI/azuresqlmi-assessment-sku-using-cli.md) 204 | - [PowerShell](../../AzureSQLMI/assessment/PowerShell/azuresqlmi-assessment-sku-using-ps.md) 205 | - ***Offline migration using Storage Account*** 206 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) 207 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-azure-storage-ps.md) 208 | - ***Offline migration using File Share*** 209 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) 210 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 211 | - ***Online migration using Storage Account*** 212 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) 213 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-online-migration-using-azure-storage-ps.md) 214 | - ***Online migration using File Share*** 215 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) 216 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 217 | - ***Login migration*** 218 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-login-migration-using-cli.md) 219 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-login-migration-using-ps.md) 220 | -------------------------------------------------------------------------------- /AzureSQLDB/deploy/terraform/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform 2 | .terraform* 3 | *.png 4 | *. 5 | *.tfstate* 6 | *.out -------------------------------------------------------------------------------- /AzureSQLDB/deploy/terraform/terraform.tfvars: -------------------------------------------------------------------------------- 1 | resource_group_name = "rg-one-click-poc" 2 | resource_group_location = "westeurope" 3 | migration_service_name = "PoCMigrationService" 4 | sql_server_name = "sqldb" 5 | sql_administrator_login = "sqladmin" 6 | sql_administrator_login_password = "My$upp3r$ecret" 7 | database_name="AdventureWorks" 8 | public_ip_address_type = "Dynamic" 9 | public_ip_address_sku = "Basic" 10 | sql_vm_name = "sqlvm-001" 11 | virtual_machine_size = "Standard_D8s_v3" 12 | image_offer = "sql2019-ws2019" 13 | sql_sku = "SQLDEV" 14 | data_path = "F:\\SQLData" 15 | log_path = "G:\\SQLLog" 16 | temp_db_path = "D:\\SQLTemp" 17 | vnet_address_prefix = "10.0.0.0/16" 18 | subnet1_prefix = "10.0.0.0/24" 19 | subnet1_name = "default" 20 | private_endpoint_name = "myPrivateEndpoint" 21 | jb_vm_name = "jb-migration" 22 | jb_interface_name = "jumpbox-migration-nic" 23 | jb_nsg_name = "jumpbox-migration-nsg" 24 | jb_ip_address_name = "jumpbox-migration-ip" 25 | jb_vnet_name = "jumpbox-migration-vnet" 26 | admin_username = "sqladmin" 27 | admin_password = "My$upp3r$ecret" 28 | sql_data_disk_count = 1 29 | sql_log_disk_count = 1 30 | -------------------------------------------------------------------------------- /AzureSQLDB/deploy/terraform/variables.tf: -------------------------------------------------------------------------------- 1 | variable "suffix" { 2 | type = string 3 | } 4 | variable "resource_group_name" { 5 | type = string 6 | } 7 | 8 | variable "resource_group_location" { 9 | type = string 10 | } 11 | 12 | variable "migration_service_name" { 13 | type = string 14 | } 15 | 16 | variable "sql_server_name" { 17 | type = string 18 | } 19 | 20 | variable "sql_administrator_login" { 21 | type = string 22 | } 23 | 24 | variable "sql_administrator_login_password" { 25 | type = string 26 | } 27 | 28 | variable "database_name" { 29 | type = string 30 | } 31 | 32 | variable "public_ip_address_type" { 33 | type = string 34 | } 35 | variable "public_ip_address_sku" { 36 | type = string 37 | } 38 | variable "sql_vm_name" { 39 | type = string 40 | } 41 | variable "virtual_machine_size" { 42 | type = string 43 | } 44 | variable "image_offer" { 45 | type = string 46 | } 47 | variable "sql_sku" { 48 | type = string 49 | } 50 | variable "sql_data_disk_count" { 51 | type = number 52 | } 53 | 54 | variable "data_path" { 55 | type = string 56 | } 57 | 58 | variable "sql_log_disk_count" { 59 | type = number 60 | } 61 | 62 | variable "log_path" { 63 | type = string 64 | } 65 | 66 | variable "admin_username" { 67 | type = string 68 | } 69 | 70 | variable "admin_password" { 71 | type = string 72 | } 73 | 74 | variable "temp_db_path" { 75 | type = string 76 | } 77 | 78 | variable "vnet_address_prefix" { 79 | type = string 80 | } 81 | 82 | variable "subnet1_prefix" { 83 | type = string 84 | } 85 | 86 | variable "subnet1_name" { 87 | type = string 88 | } 89 | 90 | variable "private_endpoint_name" { 91 | type = string 92 | } 93 | 94 | variable "jb_vm_name" { 95 | type = string 96 | } 97 | 98 | variable "jb_interface_name" { 99 | type = string 100 | } 101 | 102 | variable "jb_nsg_name" { 103 | type = string 104 | } 105 | 106 | variable "jb_ip_address_name" { 107 | type = string 108 | } 109 | 110 | variable "jb_vnet_name" { 111 | type = string 112 | } 113 | 114 | -------------------------------------------------------------------------------- /AzureSQLDB/migration/PowerShell/azuresqldb-offline-migration-using-ps.md: -------------------------------------------------------------------------------- 1 | # Offline migration for Azure SQL Database using PowerShell 2 | 3 | Perform offline migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ## Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 (Already installed) 9 | - Az.DataMigration PowerShell module 10 | 11 | ## Getting Started 12 | 13 | > [!CAUTION] 14 | > 15 | > - **Connect to the Jump Box VM** 16 | > - VM name: **jb-migration** 17 | > - Use the credentials provided on the deploy page. 18 | 19 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 20 | 21 | 1. Run the following to log in from your client using your default web browser if you are not logged in. 22 | 23 | ```powershell 24 | Connect-AzAccount -Subscription 25 | ``` 26 | 27 | If you have more than one subscription, you can select a particular subscription. 28 | 29 | ```powershell 30 | Set-AzContext -SubscriptionId 31 | ``` 32 | 33 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 34 | 35 | In addition, the PowerShell command [Data Migration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0#data-migrationt) can be used to manage data migration at scale. 36 | 37 | ### Register Database Migration Service with self-hosted Integration Runtime 38 | 39 | 1. Use the **Get-AzDataMigrationSqlServiceAuthKey** command to obtain AuthKeys. 40 | 41 | ```powershell 42 | $AuthKeys = Get-AzDataMigrationSqlServiceAuthKey ` 43 | -ResourceGroupName "" ` 44 | -SqlMigrationServiceName "PoCMigrationService" 45 | ``` 46 | 47 | - The following example obtains the authKey: 48 | 49 | ```powershell 50 | $AuthKeys = Get-AzDataMigrationSqlServiceAuthKey ` 51 | -ResourceGroupName "oneclickpoc" ` 52 | -SqlMigrationServiceName "PoCMigrationService" 53 | ``` 54 | 55 | 2. Change the PowerShell execution policy. 56 | 57 | ```powershell 58 | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 59 | ``` 60 | 61 | 3. Use the **az datamigration register-integration-runtime** command to register the service on Integration Runtime. 62 | 63 | ```powershell 64 | Register-AzDataMigrationIntegrationRuntime ` 65 | -AuthKey ` 66 | ``` 67 | 68 | The following example registers the service on Integration Runtime: 69 | 70 | ```powershell 71 | Register-AzDataMigrationIntegrationRuntime ` 72 | -AuthKey $AuthKeys.AuthKey1 ` 73 | ``` 74 | 75 | > [!WARNING] 76 | > 77 | > If you receive an error message saying: "RegisterIntegrationRuntime.ps1 cannot be loaded because running scripts is disabled on this system", please, run the following command and re-run the PowerShell command above. 78 | > 79 | > `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned` 80 | 81 | ### Perform a schema migration 82 | 83 | Performing a schema migration can be accomplished using [***SqlPackage***](https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage?view=sql-server-ver16). 84 | 85 | **SqlPackage.exe** is a command-line utility that automates the following database development tasks by exposing some of the public Data-Tier Application Framework (DacFx). 86 | 87 | - **Extract metadata** 88 | 89 | Use the **SqlPackage /Action:Extract** command to extract metadata from your source 90 | 91 | ```powershell 92 | SqlPackage /Action:Extract ` 93 | /TargetFile:"C:\temp\projects\adventureworks2019.dacpac" ` 94 | /p:ExtractAllTableData=false ` 95 | /p:ExtractReferencedServerScopedElements=true ` 96 | /p:VerifyExtraction=true ` 97 | /SourceServerName:"10.0.0.4" ` 98 | /SourceDatabaseName:"AdventureWorks2019" ` 99 | /SourceUser:"sqladmin" ` 100 | /SourcePassword:"My`$upp3r`$ecret" ` 101 | /SourceTrustServerCertificate:true 102 | ``` 103 | 104 | - **Publish metadata** 105 | 106 | Use the **SqlPackage /Action:Publish** command to publish metadata to your Azure SQL database 107 | 108 | ```powershell 109 | SqlPackage /Action:Publish ` 110 | /SourceFile:"C:\temp\projects\adventureworks2019.dacpac" ` 111 | /p:CreateNewDatabase=false ` 112 | /p:AllowIncompatiblePlatform=true ` 113 | /p:ExcludeObjectTypes="Users;RoleMembership" ` 114 | /Diagnostics:false ` 115 | /TargetServerName:".database.windows.net" ` 116 | /TargetDatabaseName:"AdventureWorks" ` 117 | /TargetUser:"sqladmin" ` 118 | /TargetPassword:"My`$upp3r`$ecret" ` 119 | /TargetTrustServerCertificate:true 120 | ``` 121 | 122 | > [!NOTE] 123 | > 124 | > This command may take 3-5 minutes to complete. 125 | 126 | You can also migrate the database schema from source to target using the [SQL Database Projects extension](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/sql-database-project-extension?view=sql-server-ver16) for Azure Data Studio. 127 | 128 | ### Start Database Migration 129 | 130 | 1. Convert the passwords to secure string 131 | 132 | ```powershell 133 | $sourcePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 134 | $targetPassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 135 | ``` 136 | 137 | 2. Use the **New-AzDataMigrationToSqlDb** command to create and start a database migration 138 | 139 | ```powershell 140 | 141 | New-AzDataMigrationToSqlDb ` 142 | -ResourceGroupName ` 143 | -SqlDbInstanceName ` 144 | -Kind "SqlDb" ` 145 | -TargetDbName AdventureWorks ` 146 | -SourceDatabaseName AdventureWorks2019 ` 147 | -SourceSqlConnectionAuthentication SQLAuthentication ` 148 | -SourceSqlConnectionDataSource 10.0.0.4 ` 149 | -SourceSqlConnectionUserName sqladmin ` 150 | -SourceSqlConnectionPassword $sourcePassword ` 151 | -Scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/servers/" ` 152 | -TargetSqlConnectionAuthentication SQLAuthentication ` 153 | -TargetSqlConnectionDataSource .database.windows.net ` 154 | -TargetSqlConnectionUserName sqladmin ` 155 | -TargetSqlConnectionPassword $targetPassword ` 156 | -MigrationService "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/sqlMigrationServices/PoCMigrationService" 157 | ``` 158 | 159 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 160 | 161 | ```powershell 162 | New-AzDataMigrationToSqlDb ` 163 | -ResourceGroupName oneclickpoc ` 164 | -SqlDbInstanceName sqlservercsapocmigration ` 165 | -Kind "SqlDb" ` 166 | -TargetDbName AdventureWorks ` 167 | -SourceDatabaseName AdventureWorks2019 ` 168 | -SourceSqlConnectionAuthentication SQLAuthentication ` 169 | -SourceSqlConnectionDataSource 10.0.0.4 ` 170 | -SourceSqlConnectionUserName sqladmin ` 171 | -SourceSqlConnectionPassword $sourcePassword ` 172 | -Scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/servers/sqlservercsapocmigration" ` 173 | -TargetSqlConnectionAuthentication SQLAuthentication ` 174 | -TargetSqlConnectionDataSource sqlservercsapocmigration.database.windows.net ` 175 | -TargetSqlConnectionUserName sqladmin ` 176 | -TargetSqlConnectionPassword $targetPassword ` 177 | -MigrationService "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/sqlMigrationServices/PoCMigrationService" 178 | ``` 179 | 180 | > [!NOTE] 181 | > 182 | > Migration may take a while to complete. 183 | 184 | Learn more about using [PowerShell to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-to-sql-db.md) 185 | 186 | ### Monitoring migration 187 | 188 | Use the **Get-AzDataMigrationToSqlDb** command to monitor migration. 189 | 190 | 1. Get complete migration details 191 | 192 | ```powershell 193 | $monitoringMigration = Get-AzDataMigrationToSqlDb ` 194 | -ResourceGroupName ` 195 | -SqlDbInstanceName ` 196 | -TargetDbName AdventureWorks ` 197 | -Expand MigrationStatusDetails 198 | 199 | $monitoringMigration 200 | ``` 201 | 202 | The following example brings complete details 203 | 204 | ```powershell 205 | 206 | $monitoringMigration = Get-AzDataMigrationToSqlDb ` 207 | -ResourceGroupName oneclickpoc ` 208 | -SqlDbInstanceName sqlservercsapocmigration ` 209 | -TargetDbName AdventureWorks ` 210 | -Expand MigrationStatusDetails 211 | 212 | $monitoringMigration 213 | 214 | ``` 215 | 216 | 2. ProvisioningState should be **Creating, Failed, or Succeeded** 217 | 218 | ```powershell 219 | $monitoringMigration = Get-AzDataMigrationToSqlDb ` 220 | -ResourceGroupName ` 221 | -SqlDbInstanceName ` 222 | -TargetDbName AdventureWorks ` 223 | -Expand MigrationStatusDetails 224 | 225 | $monitoringMigration.ProvisioningState | Format-List 226 | ``` 227 | 228 | The following example brings complete details 229 | 230 | ```powershell 231 | 232 | $monitoringMigration = Get-AzDataMigrationToSqlDb ` 233 | -ResourceGroupName oneclickpoc ` 234 | -SqlDbInstanceName sqlservercsapocmigration ` 235 | -TargetDbName AdventureWorks ` 236 | -Expand MigrationStatusDetails 237 | 238 | $monitoringMigration.ProvisioningState | Format-List 239 | 240 | ``` 241 | 242 | 3. MigrationStatus should be **InProgress, Canceling, Failed, or Succeeded** 243 | 244 | ```powershell 245 | $monitoringMigration = Get-AzDataMigrationToSqlDb ` 246 | -ResourceGroupName ` 247 | -SqlDbInstanceName ` 248 | -TargetDbName AdventureWorks ` 249 | -Expand MigrationStatusDetails 250 | 251 | $monitoringMigration.MigrationStatus | Format-List 252 | ``` 253 | 254 | The following example brings complete details 255 | 256 | ```powershell 257 | 258 | $monitoringMigration = Get-AzDataMigrationToSqlDb ` 259 | -ResourceGroupName oneclickpoc ` 260 | -SqlDbInstanceName sqlservercsapocmigration ` 261 | -TargetDbName AdventureWorks ` 262 | -Expand MigrationStatusDetails 263 | 264 | $monitoringMigration.MigrationStatus | Format-List 265 | ``` 266 | 267 | You can also use the Azure Portal to monitor migration. 268 | 269 | ![migration succeeded](/media/sqldb-migration-succeeded.png) 270 | 271 | ## Migrating at scale 272 | 273 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/PowerShell/scripts/multiple%20databases) 274 | 275 | ## Page Navigator 276 | 277 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 278 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 279 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 280 | -------------------------------------------------------------------------------- /AzureSQLMI/assessment/ADS/azuresqlmi-assessment-sku-using-ads.md: -------------------------------------------------------------------------------- 1 | # Assessment and SKU recommendation for Azure SQL Managed Instance using Azure Data Studio 2 | 3 | Assess your SQL Server databases for Azure SQL Managed Instance readiness or to identify any migration blockers before migrating them to Azure SQL Managed Instance. 4 | 5 | [Azure Data Studio](https://learn.microsoft.com/en-us/azure-data-studio/what-is-azure-data-studio) is a unified tooling experience for data professionals. 6 | Designed to focus on the functionality data platform developers use the most, Azure Data Studio offers additional experiences available as optional extensions. It's built for data professionals who use SQL Server and Azure databases on-premises or in multicloud environments. 7 | 8 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure SQL. 9 | 10 | ## Prerequisites 11 | 12 | - SQL Server with Windows authentication or SQL authentication access 13 | 14 | ## Getting Started 15 | 16 | > [!CAUTION] 17 | > 18 | > - **Connect to the Jump Box VM** 19 | > - VM name: **jb-migration** 20 | > - Use the credentials provided on the deploy page. 21 | 22 | ## Installing Azure SQL Migration Extension 23 | 24 | - Launch Azure Data Studio. 25 | - Navigate to the "Extensions" tab located in the right-side menu. 26 | - In the search bar, type "Azure SQL Migration" and press Enter. 27 | - Locate the "Azure SQL Migration" extension from the search results. 28 | - Click on the "Install" button next to the extension to begin the installation process. 29 | 30 | ![ads-assessment-install-extension](../../../media/ADS/ads-assessment-install-extension.png) 31 | 32 | ## Connecting to SQL Server 33 | 34 | After successfully installing the extension, follow these steps to connect to the SQL Server: 35 | 36 | - Navigate to the "Connections" tab in the top menu. 37 | - Click on "New Connection" to open the connection dialog. 38 | - In the "Server" field, enter the following: `10.1.0.4` 39 | - Choose "Windows Authentication" as the authentication type. 40 | - Set "Trust server certificate" to "True". 41 | - Click "Connect" to establish the connection to the SQL Server. 42 | 43 | ![ads-assessment-connect-sql](/media/ADS/ads-sqlmi-assessment-connect-sql.png) 44 | 45 | After establishing the connection, the Manage page will appear. 46 | 47 | - Go to the sidebar menu and select "General" to find the "Azure SQL Migration" extension. 48 | - Click on the "Azure SQL Migration" extension to open it and begin using its features for migration tasks. 49 | 50 | ## Exploring Azure SQL Migration Extension 51 | 52 | After accessing the home page of Azure SQL Migration, follow these steps: 53 | 54 | - Look for the "+ New migration" button and click on it. 55 | - Choose all databases that you want to include in the assessment. 56 | - Click "Next" to proceed to the next step in the migration process. 57 | 58 | ![ads-assessment-migration-extension-home](/media/ADS/ads-sqlmi-assessment-migration-extension-home.png) 59 | 60 | - Click on the checkbox to select all databases available for assessment. 61 | - Alternatively, individually check the checkboxes next to each database to select them manually. 62 | - Once all databases are selected, proceed to the next step in the migration process. 63 | 64 | ![ads-assessment-select-databases](/media/ADS/ads-sqlmi-assessment-select-databases.png) 65 | 66 | ## Performance data collection and SKU recommendation 67 | 68 | - After a few minutes, a summary will appear, allowing you to review the assessment for Azure SQL targets. 69 | - To begin collecting data from your databases to determine the best SKU, click on "Start Data Collection". This will initiate the data collection process. 70 | - Alternatively, if you have already collected data, you can import it. 71 | 72 | ![ads-assessment-summary](/media/ADS/ads-sqlmi-assessment-summary.png) 73 | 74 | - You need to wait for approximately 10 minutes before you can start seeing recommendations. 75 | - After this time, you'll be able to explore the SKU recommendations. 76 | - To stop collecting data, click on "Stop Data Collection". 77 | 78 | ![ads-assessment-sku-recommendation.png](/media/ADS/ads-sqlmi-assessment-sku-recommendation.png) 79 | 80 | - When you click on "View Details," you'll access a detailed report for the SKU recommended. 81 | - Additionally, you have the option to save the recommendation report. 82 | 83 | ![ads-assessment-sku-recommendation-view-details.png](/media/ADS/ads-sqlmi-assessment-sku-recommendation-view-details.png) 84 | 85 | ## Reviewing the assessment 86 | 87 | After reviewing the SKU recommendation, click on the "Close" button to return to the summary page. From there, proceed by clicking "Next" to review any issues or blockers. 88 | 89 | - Select "Azure SQL Managed Instance" as the target type. 90 | - Navigate to the database named "AdventureWorksTDE". 91 | - Click on the findings to view detailed information about the issues. 92 | - Review issues or blockers for a specific database. 93 | 94 | ![ads-assessment-target-platform](/media/ADS/ads-sqlmi-assessment-target-platform.png) 95 | 96 | You can save your assessment and review it later. 97 | 98 | ## Page Navigator 99 | 100 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 101 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 102 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 103 | -------------------------------------------------------------------------------- /AzureSQLMI/assessment/CLI/azuresqlmi-assessment-sku-using-cli.md: -------------------------------------------------------------------------------- 1 | # Assessment and SKU recommendation for Azure SQL Managed Instance using CLI 2 | 3 | Assess your SQL Server databases for Azure SQL Managed Instance readiness or to identify any migration blockers before migrating them to Azure SQL Managed Instance. 4 | 5 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure SQL. 6 | 7 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 8 | 9 | ## Prerequisites 10 | 11 | - SQL Server with Windows authentication or SQL authentication access 12 | - .Net Core 3.1 (Already installed) 13 | - Azure CLI (Already installed) 14 | - Az datamigration extension 15 | 16 | ## Getting Started 17 | 18 | > [!CAUTION] 19 | > 20 | > - **Connect to the Jump Box VM** 21 | > - VM name: **jb-migration** 22 | > - Use the credentials provided on the deploy page. 23 | 24 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 25 | 26 | 1. Install az datamigration extension. Open either a command shell or PowerShell as administrator. 27 | 28 | ```azurecli 29 | az extension add --name datamigration 30 | ``` 31 | 32 | 2. Run the following to log in from your client using your default web browser 33 | 34 | ```azurecli 35 | az login 36 | ``` 37 | 38 | If you have more than one subscription, you can select a particular subscription. 39 | 40 | ```azurecli 41 | az account set --subscription 42 | ``` 43 | 44 | ## Run the assessment 45 | 46 | 1. Run a SQL Server assessment using the ***az datamigration get-assessment*** command. 47 | 48 | ```azurecli 49 | az datamigration get-assessment ` 50 | --connection-string "Data Source=10.1.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 51 | --output-folder "C:\temp\output" ` 52 | --overwrite 53 | ``` 54 | 55 | 2. **Assessment at scale** using config file 56 | 57 | You can also create a config file to use as a parameter to run assessment on SQL servers. The config file has the following structure: 58 | 59 | ```json 60 | { 61 | "action": "Assess", 62 | "outputFolder": "C:\\temp\\output", 63 | "overwrite": "True", 64 | "sqlConnectionStrings": [ 65 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 66 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 67 | ] 68 | } 69 | ``` 70 | 71 | The config file can be passed to the cmdlet in the following way 72 | 73 | ```azurecli 74 | az datamigration get-assessment --config-file-path "C:\Users\user\document\config.json" 75 | ``` 76 | 77 | > [!TIP] 78 | > To view the report, go to **C:\temp\output** folder and check the json file. 79 | 80 | Learn more about using [CLI to assess SQL Server](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-assessment.md) 81 | 82 | ## SKU Recommendation 83 | 84 | ### Performance data collection 85 | 86 | This step is optional. An Azure SQL Managed Instance has been already provisioned. 87 | 88 | 1. Run a SQL Server performance data collection using the ***az datamigration performance-data-collection*** command. 89 | 90 | ```azurecli 91 | az datamigration performance-data-collection ` 92 | --connection-string "Data Source=10.1.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 93 | --output-folder "C:\temp\output" ` 94 | --perf-query-interval 10 ` 95 | --number-of-iteration 5 ` 96 | --static-query-interval 120 97 | ``` 98 | 99 | > [!TIP] 100 | > Collect as much data as you want, then stop the process. 101 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 102 | 103 | 2. Running **performance data collection at scale** using a config file 104 | 105 | You can also create a config file to use as a parameter to run performance data collection on SQL servers. 106 | The config file has the following structure: 107 | 108 | ```json 109 | { 110 | "action": "PerfDataCollection", 111 | "outputFolder": "C:\\temp\\output", 112 | "perfQueryIntervalInSec": 20, 113 | "staticQueryIntervalInSec": 120, 114 | "numberOfIterations": 7, 115 | "sqlConnectionStrings": [ 116 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 117 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 118 | ] 119 | } 120 | ``` 121 | 122 | The config file can be passed to the cmdlet in the following way. 123 | 124 | ```azurecli 125 | az datamigration performance-data-collection --config-file-path "C:\Users\user\document\config.json" 126 | ``` 127 | 128 | > [!TIP] 129 | > Collect as much data as you want, then stop the process. 130 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 131 | 132 | Learn more about using [CLI to perform data collection](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-sku-recommendation.md) 133 | 134 | ### Get SKU Recommendation 135 | 136 | This step is optional. An Azure SQL Managed Instance has been already provisioned. 137 | 138 | 1. Get SKU recommendation using the **az datamigration get-sku-recommendation** command. 139 | 140 | ```azurecli 141 | az datamigration get-sku-recommendation ` 142 | --output-folder "C:\temp\output" ` 143 | --display-result ` 144 | --overwrite ` 145 | --target-platform "AzureSqlManagedInstance" 146 | ``` 147 | 148 | All results will be displayed after the command finishes. 149 | 150 | ![sqlmi-sku-recommendation](../../../media/sqlmi-sku-recommendation-cli.png) 151 | 152 | 2. Get SKU recommendations at scale using a config file. 153 | 154 | You can also create a config file to use as a parameter to get SKU recommendations on SQL servers. The config file has the following structure: 155 | 156 | ```json 157 | { 158 | "action": "GetSKURecommendation", 159 | "outputFolder": "C:\\temp\\Output", 160 | "overwrite": "True", 161 | "displayResult": "True", 162 | "targetPlatform": "any", 163 | "scalingFactor": 1000 164 | } 165 | ``` 166 | 167 | Learn more about using [CLI to get SKU recommendation](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-sku-recommendation.md#get-sku-recommendation-though-console-parameters) 168 | 169 | ### View Assessment & SKU Recommendation 170 | 171 | 1. **HTML recommendations result** 172 | 173 | You can look into the output folder (C:\temp\output) to find an HTML file that also gives the details of the SKU being recommended. 174 | 175 | ![sqlmi-sku-recommendation-html](../../../media/sqlmi-sku-recommendation-html.png) 176 | 177 | ## Page Navigator 178 | 179 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 180 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 181 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 182 | -------------------------------------------------------------------------------- /AzureSQLMI/assessment/PowerShell/azuresqlmi-assessment-sku-using-ps.md: -------------------------------------------------------------------------------- 1 | # Assessment and SKU recommendation for Azure SQL Managed Instance using PowerShell 2 | 3 | Assess your SQL Server databases for Azure SQL Managed Instance readiness or to identify any migration blockers before migrating them to Azure SQL Managed Instance. 4 | 5 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure SQL. 6 | 7 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 8 | 9 | ## Prerequisites 10 | 11 | - SQL Server with Windows authentication or SQL authentication access 12 | - .Net Core 3.1 (Already installed) 13 | - Az.DataMigration PowerShell module 14 | 15 | ## Getting Started 16 | 17 | > [!CAUTION] 18 | > 19 | > - **Connect to the Jump Box VM** 20 | > - VM name: **jb-migration** 21 | > - Use the credentials provided on the deploy page. 22 | 23 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 24 | 25 | ## Run the assessment 26 | 27 | 1. Run a SQL Server assessment using the ***Get-AzDataMigrationAssessment*** command. 28 | 29 | ```powershell 30 | Get-AzDataMigrationAssessment ` 31 | -ConnectionString "Data Source=10.1.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 32 | -OutputFolder "C:\temp\output" ` 33 | -Overwrite 34 | ``` 35 | 36 | 2. **Assessment at scale** using config file 37 | 38 | You can also create a config file to use as a parameter to run assessment on SQL servers. The config file has the following structure: 39 | 40 | ```json 41 | { 42 | "action": "Assess", 43 | "outputFolder": "C:\\temp\\output", 44 | "overwrite": "True", 45 | "sqlConnectionStrings": [ 46 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 47 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 48 | ] 49 | } 50 | ``` 51 | 52 | The config file can be passed to the cmdlet in the following way 53 | 54 | ```powershell 55 | Get-AzDataMigrationAssessment -ConfigFilePath "C:\Users\user\document\config.json" 56 | ``` 57 | 58 | > [!TIP] 59 | > To view the report, go to **C:\temp\output** folder and check the json file. 60 | 61 | Learn more about using [PowerShell to assess SQL Server](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-assessment.md) 62 | 63 | ## SKU Recommendation 64 | 65 | ### Performance data collection 66 | 67 | This step is optional. An Azure SQL Managed Instance has been already provisioned. 68 | 69 | 1. Run a SQL Server performance data collection using the ***Get-AzDataMigrationPerformanceDataCollection*** command. 70 | 71 | ```powershell 72 | Get-AzDataMigrationPerformanceDataCollection ` 73 | -SqlConnectionStrings "Data Source=10.1.0.4,1433;Initial Catalog=master;User Id=sqladmin;Password=My`$upp3r`$ecret" ` 74 | -OutputFolder "C:\temp\output" ` 75 | -PerfQueryInterval 10 ` 76 | -NumberOfIterations 5 ` 77 | -StaticQueryInterval 120 78 | ``` 79 | 80 | > [!TIP] 81 | > Collect as much data as you want, then stop the process. 82 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 83 | 84 | 2. Running **performance data collection at scale** using a config file 85 | 86 | You can also create a config file to use as a parameter to run performance data collection on SQL servers. 87 | The config file has the following structure: 88 | 89 | ```json 90 | { 91 | "action": "PerfDataCollection", 92 | "outputFolder": "C:\\temp\\output", 93 | "perfQueryIntervalInSec": 20, 94 | "staticQueryIntervalInSec": 120, 95 | "numberOfIterations": 7, 96 | "sqlConnectionStrings": [ 97 | "Data Source=Server1.database.net;Initial Catalog=master;Integrated Security=True;", 98 | "Data Source=Server2.database.net;Initial Catalog=master;Integrated Security=True;" 99 | ] 100 | } 101 | ``` 102 | 103 | The config file can be passed to the cmdlet in the following way. 104 | 105 | ```powershell 106 | Get-AzDataMigrationPerformanceDataCollection -ConfigFilePath "C:\Users\user\document\config.json" 107 | ``` 108 | 109 | > [!TIP] 110 | > Collect as much data as you want, then stop the process. 111 | > You can look into the output folder (**C:\temp\output**) to find a CSV file that also gives the details of the performance data collected. 112 | 113 | Learn more about using [PowerShell to perform data collection](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-sku-recommendation.md) 114 | 115 | ### Get SKU Recommendation 116 | 117 | This step is optional. An Azure SQL Managed Instance has been already provisioned. 118 | 119 | 1. Get SKU recommendation using the **az datamigration get-sku-recommendation** command. 120 | 121 | ```powershell 122 | Get-AzDataMigrationSkuRecommendation ` 123 | -OutputFolder "C:\temp\output" ` 124 | -DisplayResult ` 125 | -Overwrite ` 126 | -TargetPlatform "AzureSqlManagedInstance" 127 | ``` 128 | 129 | All results will be displayed after the command finishes. 130 | 131 | ![sqlmi-sku-recommendation](../../../media/sqlmi-sku-recommendation-cli.png) 132 | 133 | 2. Get SKU recommendations at scale using a config file. 134 | 135 | You can also create a config file to use as a parameter to get SKU recommendations on SQL servers. The config file has the following structure: 136 | 137 | ```json 138 | { 139 | "action": "GetSKURecommendation", 140 | "outputFolder": "C:\\temp\\Output", 141 | "overwrite": "True", 142 | "displayResult": "True", 143 | "targetPlatform": "any", 144 | "scalingFactor": 1000 145 | } 146 | ``` 147 | 148 | Learn more about using [PowerShell to get SKU recommendation](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-sku-recommendation.md#get-sku-recommendation-though-console-parameters) 149 | 150 | ### View Assessment & SKU Recommendation 151 | 152 | 1. **HTML recommendations result** 153 | 154 | You can look into the output folder (C:\temp\output) to find an HTML file that also gives the details of the SKU being recommended. 155 | 156 | ![sqlmi-sku-recommendation-html](../../../media/sqlmi-sku-recommendation-html.png) 157 | 158 | ## Page Navigator 159 | 160 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 161 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 162 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) -------------------------------------------------------------------------------- /AzureSQLMI/deploy/README.md: -------------------------------------------------------------------------------- 1 | # Deploy the solution for Azure SQL Managed Instance 2 | 3 | In this section, you will provision all Azure resources required to complete this PoC. 4 | 5 | ## Deployment options 6 | 7 | | Deployment language | | 8 | | :-------------------------------: | :----------------------------------------------------------------------------------: | 9 | |[**ARM**](#azure-resource-manager) | [![azure resource manager](../../media/ARM-Deployment.svg)](#azure-resource-manager) | 10 | |[**Bicep**](#bicep) | [![bicep](../../media/Bicep-Logo.svg)](#bicep) | 11 | |[**Terraform**](#terraform) | [![terraform](../../media/Terraform-Logo.svg)](#terraform) | 12 | 13 | ## Deployment diagram 14 | 15 | ![resource-visualizer](/media/sqlmi-resource-visualizer.png) 16 | 17 | ## Azure Resource Manager 18 | 19 | [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FSQL-Migration-AzureSQL-PoC%2Fmain%2FAzureSQLMI%2Fdeploy%2Farm%2Ftemplate-latest.json) 20 | 21 | The [ARM template (template-latest.json)](arm/template-latest.json) is used to provision Azure resources in a resource group. 22 | 23 | Right-click or `Ctrl + click` the button below to open the Azure Portal in a new window. This will redirect you to the Custom Deployment wizard in the Azure Portal. 24 | 25 | Select the Azure subscription and the resource group that you would like to use for this PoC. 26 | 27 | ## Bicep 28 | 29 | The [Bicep template (template-latest.bicep)](bicep/template-latest.bicep) is used to provision Azure resources in a resource group. 30 | 31 | [Learn more about bicep](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview?tabs=bicep). 32 | 33 | ### Prerequisites 34 | 35 | - [Install Bicep tools](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/install#azure-cli) 36 | - [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) 37 | 38 | ### How to deploy it 39 | 40 | 1. Run the following to log in from your client using your default web browser 41 | 42 | ```azurecli 43 | az login 44 | ``` 45 | 46 | If you have more than one subscription, you can select a particular subscription. 47 | 48 | ```azurecli 49 | az account set --subscription 50 | ``` 51 | 52 | 2. Find a location you want to deploy the resource group 53 | 54 | ```azurecli 55 | az account list-locations -o table 56 | ``` 57 | 58 | 3. Create a resource group 59 | 60 | ```azurecli 61 | az group create --location "" --name "" 62 | ``` 63 | 64 | The following example deploys a resource group in North Europe 65 | 66 | ```azurecli 67 | az group create --location "northeurope" --name "one-click-poc" 68 | ``` 69 | 70 | 4. Deploy a bicep template 71 | 72 | ```azurecli 73 | az deployment group create --resource-group "" --template-file C:\temp\bicep\template-latest.bicep 74 | 75 | ``` 76 | 77 | The following example deploys a bicep template 78 | 79 | ```azurecli 80 | az deployment group create --resource-group "one-click-poc" --template-file C:\temp\bicep\template-latest.bicep 81 | ``` 82 | 83 | ## Terraform 84 | 85 | The [Terraform template (terraform/template-latest.tf)](terraform/template-latest.tf) is used to provision Azure resources in a resource group. 86 | 87 | [Learn more about Terraform](https://learn.microsoft.com/en-us/azure/developer/terraform/overview). 88 | 89 | Prerequisites 90 | 91 | - [Install Terraform](https://learn.microsoft.com/en-us/azure/developer/terraform/quickstart-configure) 92 | - [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) 93 | 94 | 1. Run the following to log in from your client using your default web browser 95 | 96 | ```azurecli 97 | az login 98 | ``` 99 | 100 | If you have more than one subscription, you can select a particular subscription. 101 | 102 | ```azurecli 103 | az account set --subscription 104 | ``` 105 | 106 | 2. Find a location you want to deploy the resource group 107 | 108 | ```azurecli 109 | az account list-locations -o table 110 | ``` 111 | 112 | 3. Move to the folder [AzureSQLMI/deploy/terraform](AzureSQLMI/deploy/terraform) 113 | 114 | ```azurecli 115 | cd AzureSQLMI/deploy/terraform 116 | ``` 117 | 118 | 4. Open the file [terraform.tfvars](terraform/terraform.tfvars) and provide values for the variables `resource_group_name` and `resource_group_location` 119 | 120 | e.g: 121 | 122 | ```azurecli 123 | resource_group_name = "one-click-poc" 124 | resource_group_location = "westeurope" 125 | ``` 126 | 127 | 5. Initialize a working directory for the terraform configuration 128 | 129 | ```azurecli 130 | terraform init 131 | ``` 132 | 133 | 6. Deploy the terraform template 134 | 135 | ```azurecli 136 | terraform apply -auto-approve 137 | ``` 138 | 139 | A message asking for input of a value for the variable `suffix` will be displayed 140 | 141 | ```azurecli 142 | var.suffix 143 | Enter a value: 144 | ``` 145 | 146 | Insert a value and press Enter. 147 | 148 | ## Azure Resources 149 | 150 | The template provisions the following resources in the Azure subscription 151 | 152 | - Azure Resource Group 153 | - Azure Storage Account 154 | - Azure SQL Managed Instance 155 | - VNet for Azure SQL Managed Instance 156 | - NSG for Azure SQL Managed Instance 157 | - Virtual network traffic routing 158 | - Azure SQL VM 159 | - Network interface for Azure SQL VM 160 | - VNet for Azure SQL VM 161 | - Public IP for Azure SQL VM 162 | - NSG for Azure SQL VM 163 | - JumpBox VM 164 | - Network interface for JumpBox VM 165 | - VNet for JumpBox VM 166 | - NSG for JumpBox VM 167 | - Public IP for JumpBox VM 168 | - Virtual network peering 169 | 170 | > [!IMPORTANT] 171 | > Please note that it takes 6 to 8 hours approximately to provision all these resources in an Azure subscription. 172 | 173 | Some of the Azure services provisioned require a globally unique name and a “suffix” has been added to their names to ensure uniqueness. 174 | 175 | | Azure Service | Name | Pricing Tier | How to | 176 | |:---- |:----- | :---- |:----- | 177 | | Resource Group | one-click-PoC | | [Create a Resource Group](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal#create-resource-groups) 178 | | Storage Account | storage*suffix* | |[Create a storage account](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-portal)| 179 | | SQL Server on Azure VM | sqlvm-001 | Standard_D8s_v3 |[Provision SQL Server on Azure VM](https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/create-sql-vm-portal?view=azuresql) | 180 | | Azure SQL Managed Instance | sqlmi-*suffix* | GP_Gen5 8vCore |[Create an Azure SQL Managed Instance](https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/instance-create-quickstart?view=azuresql)| 181 | | Azure VM | jb-migration | Standard_B4ms |[Create a Windows virtual machine](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal) | 182 | 183 | ### Credential 184 | 185 | | | Admin User Name | Password | 186 | |:---- |:----- | :---- | 187 | | SQL VM | sqladmin | My\$upp3r\$ecret | 188 | | Azure SQL Database | sqladmin | My\$upp3r\$ecret | 189 | | JumpBox VM | sqladmin | My\$upp3r\$ecret | 190 | 191 | ## Page Navigator 192 | 193 | - [SQL Server migration one-click PoC to Azure SQL](../../README.md) 194 | 195 | - [One-click PoC to Azure SQL DB](../../AzureSQLDB/deploy/README.md) 196 | - ***Assessment and SKU recommendation*** 197 | - [CLI](../../AzureSQLDB/assessment/CLI/azuresqldb-assessment-sku-using-cli.md) 198 | - [PowerShell](../../AzureSQLDB/assessment/PowerShell/azuresqldb-assessment-sku-using-ps.md) 199 | - ***Offline migration*** 200 | - [CLI](../../AzureSQLDB/migration/CLI/azuresqldb-offline-migration-using-cli.md) 201 | - [PowerShell](../../AzureSQLDB/migration/PowerShell/azuresqldb-offline-migration-using-ps.md) 202 | 203 | - [One-click PoC to Azure SQL MI](../../AzureSQLMI/deploy/README.md) 204 | - ***Assessment and SKU recommendation*** 205 | - [CLI](../../AzureSQLMI/assessment/CLI/azuresqlmi-assessment-sku-using-cli.md) 206 | - [PowerShell](../../AzureSQLMI/assessment/PowerShell/azuresqlmi-assessment-sku-using-ps.md) 207 | - ***Offline migration using Storage Account*** 208 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) 209 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-azure-storage-ps.md) 210 | - ***Offline migration using File Share*** 211 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) 212 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 213 | - ***Online migration using Storage Account*** 214 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) 215 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-online-migration-using-azure-storage-ps.md) 216 | - ***Online migration using File Share*** 217 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) 218 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 219 | - ***Login migration*** 220 | - [CLI](../../AzureSQLMI/migration/CLI/azuresqlmi-login-migration-using-cli.md) 221 | - [PowerShell](../../AzureSQLMI/migration/PowerShell/azuresqlmi-login-migration-using-ps.md) 222 | -------------------------------------------------------------------------------- /AzureSQLMI/deploy/terraform/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform 2 | .terraform* 3 | *.png 4 | *. 5 | *.tfstate* 6 | *.out -------------------------------------------------------------------------------- /AzureSQLMI/deploy/terraform/terraform.tfvars: -------------------------------------------------------------------------------- 1 | resource_group_name = "rg-one-click-poc" 2 | resource_group_location = "westeurope" 3 | migration_service_name = "PoCMigrationService" 4 | sql_server_name = "sqldb" 5 | sql_administrator_login = "sqladmin" 6 | sql_administrator_login_password = "My$upp3r$ecret" 7 | database_name = "AdventureWorks" 8 | public_ip_address_type = "Dynamic" 9 | public_ip_address_sku = "Basic" 10 | sql_vm_name = "sqlvm-001" 11 | virtual_machine_name = "sqlvm-001" 12 | virtual_machine_size = "Standard_D8s_v3" 13 | image_offer = "sql2019-ws2019" 14 | sql_sku = "SQLDEV" 15 | data_path = "F:\\SQLData" 16 | log_path = "G:\\SQLLog" 17 | temp_db_path = "D:\\SQLTemp" 18 | vnet_address_prefix = "10.1.0.0/16" 19 | subnet1_prefix = "10.1.0.0/24" 20 | subnet1_name = "default" 21 | private_endpoint_name = "myPrivateEndpoint" 22 | jb_vm_name = "jb-migration" 23 | jb_interface_name = "jumpbox-migration-nic" 24 | jb_nsg_name = "jumpbox-migration-nsg" 25 | jb_ip_address_name = "jumpbox-migration-ip" 26 | jb_vnet_name = "jumpbox-migration-vnet" 27 | admin_username = "sqladmin" 28 | admin_password = "My$upp3r$ecret" 29 | sql_data_disk_count = 1 30 | sql_log_disk_count = 1 31 | sql_mi_administrator_login = "sqladmin" 32 | sql_mi_administratorloginpassword = "My$upp3r$ecret" 33 | sql_mi_virtualnetworkname = "vnet-sqlmi" 34 | sql_mi_address_prefix = "10.0.0.0/16" 35 | sql_mi_subnetname = "ManagedInstance" 36 | sql_mi_subnet_prefix = "10.0.0.0/24" 37 | sql_mi_sku_name = "GP_Gen5" 38 | sql_mi_vcores = 8 39 | sql_mi_storage_size_in_gb = 256 40 | sql_mi_license_type = "LicenseIncluded" 41 | disk_configuration_type = "NEW" 42 | sql_mi_management_subnet_name = "management" 43 | sql_mi_management_subnet_prefix = "10.0.1.0/24" 44 | storage_workload_type= "General" -------------------------------------------------------------------------------- /AzureSQLMI/deploy/terraform/variables.tf: -------------------------------------------------------------------------------- 1 | variable "suffix" { 2 | type = string 3 | } 4 | 5 | variable "resource_group_name" { 6 | type = string 7 | } 8 | 9 | variable "resource_group_location" { 10 | type = string 11 | } 12 | 13 | variable "migration_service_name" { 14 | type = string 15 | } 16 | 17 | variable "sql_server_name" { 18 | type = string 19 | } 20 | 21 | variable "sql_mi_administrator_login" { 22 | type = string 23 | } 24 | 25 | variable "storage_workload_type" { 26 | type = string 27 | } 28 | 29 | variable "sql_administrator_login" { 30 | type = string 31 | } 32 | 33 | variable "sql_administrator_login_password" { 34 | type = string 35 | } 36 | 37 | variable "database_name" { 38 | type = string 39 | } 40 | 41 | variable "public_ip_address_type" { 42 | type = string 43 | } 44 | variable "public_ip_address_sku" { 45 | type = string 46 | } 47 | variable "sql_vm_name" { 48 | type = string 49 | } 50 | variable "virtual_machine_name" { 51 | type = string 52 | } 53 | variable "virtual_machine_size" { 54 | type = string 55 | } 56 | variable "image_offer" { 57 | type = string 58 | } 59 | variable "sql_sku" { 60 | type = string 61 | } 62 | variable "sql_data_disk_count" { 63 | type = number 64 | } 65 | 66 | variable "data_path" { 67 | type = string 68 | } 69 | 70 | variable "sql_log_disk_count" { 71 | type = number 72 | } 73 | 74 | variable "log_path" { 75 | type = string 76 | } 77 | 78 | variable "disk_configuration_type" { 79 | type = string 80 | } 81 | 82 | variable "admin_username" { 83 | type = string 84 | } 85 | 86 | variable "admin_password" { 87 | type = string 88 | } 89 | 90 | variable "temp_db_path" { 91 | type = string 92 | } 93 | 94 | variable "vnet_address_prefix" { 95 | type = string 96 | } 97 | 98 | variable "subnet1_prefix" { 99 | type = string 100 | } 101 | 102 | variable "subnet1_name" { 103 | type = string 104 | } 105 | 106 | variable "private_endpoint_name" { 107 | type = string 108 | } 109 | 110 | variable "jb_vm_name" { 111 | type = string 112 | } 113 | 114 | variable "jb_interface_name" { 115 | type = string 116 | } 117 | 118 | variable "jb_nsg_name" { 119 | type = string 120 | } 121 | 122 | variable "jb_ip_address_name" { 123 | type = string 124 | } 125 | 126 | variable "jb_vnet_name" { 127 | type = string 128 | } 129 | 130 | variable "sql_mi_administratorloginpassword" { 131 | type = string 132 | } 133 | variable "sql_mi_virtualnetworkname" { 134 | type = string 135 | } 136 | variable "sql_mi_address_prefix" { 137 | type = string 138 | } 139 | variable "sql_mi_subnetname" { 140 | type = string 141 | } 142 | variable "sql_mi_subnet_prefix" { 143 | type = string 144 | } 145 | variable "sql_mi_sku_name" { 146 | type = string 147 | } 148 | variable "sql_mi_vcores" { 149 | type = number 150 | } 151 | variable "sql_mi_storage_size_in_gb" { 152 | type = number 153 | } 154 | variable "sql_mi_license_type" { 155 | type = string 156 | } 157 | 158 | variable "sql_mi_management_subnet_name" { 159 | type = string 160 | } 161 | variable "sql_mi_management_subnet_prefix" { 162 | type = string 163 | } 164 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/CLI/azuresqlmi-login-migration-using-cli.md: -------------------------------------------------------------------------------- 1 | # Login migration for Azure SQL Managed Instance using CLI 2 | 3 | Perform a login migration of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Managed Instance using the Azure SQL Migration extension. 4 | 5 | ## Migration using Azure storage 6 | 7 | ### Prerequisites 8 | 9 | - SQL Server with Windows authentication or SQL authentication access 10 | - .Net Core 3.1 *(Already installed)* 11 | - Azure CLI *(Already installed)* 12 | - Az datamigration extension 13 | - Azure storage account *(Already provisioned)* 14 | - Azure Data Studio *(Already installed)* 15 | - Azure SQL Migration extension for Azure Data Studio 16 | 17 | Currently, only Azure SQL Managed Instance and SQL Server on Azure Virtual Machines targets are supported. 18 | 19 | Completing the database migrations of your on-premises databases to Azure SQL before starting the login migration is ***recommended***. It will ensure that the database-level users have already been migrated to the target; therefore the login migration process will perform the user-login mappings synchronization. 20 | 21 | ## Getting Started 22 | 23 | > [!CAUTION] 24 | > 25 | > - **Connect to the Jump Box VM** 26 | > - VM name: **jb-migration** 27 | > - Use the credentials provided on the deploy page. 28 | 29 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 30 | 31 | 1. Install az datamigration extension if it isn't installed. 32 | 33 | ```azurecli 34 | az extension add --name datamigration 35 | ``` 36 | 37 | 2. Run the following to log in from your client using your default web browser 38 | 39 | ```azurecli 40 | az login 41 | ``` 42 | 43 | If you have more than one subscription, you can select a particular subscription. 44 | 45 | ```azurecli 46 | az account set --subscription 47 | ``` 48 | 49 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 50 | 51 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 52 | 53 | 3. Verify SQL Logins to be migrated 54 | 55 | Open the Azure Data Studio, connect to the *Azure SQL VM* (**10.1.0.4**) using the "**sqladmin**" user and password and run the following T-SQL statement to see all SQL Logins. 56 | 57 | ```sql 58 | SELECT 59 | sp.name AS server_login_name, 60 | dp.name AS database_user_name, 61 | sp.type_desc, 62 | sp.is_disabled 63 | FROM sys.server_principals AS sp 64 | INNER JOIN WideWorldImportersDW.sys.database_principals AS dp ON SP.sid = DP.sid 65 | ``` 66 | 67 | ### Start login migration 68 | 69 | > [!CAUTION] 70 | > 71 | > - **Connect to the Jump Box VM** 72 | > - VM name: **jb-migration** 73 | > - Use the credentials provided on the deploy page. 74 | 75 | At this point you will need to get the Azure SQL MI name. [Get server connection information](https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-content-reference-guide?view=azuresql#get-server-connection-information) 76 | 77 | ![sqlmi-connectionstring](../../../media/sqlmi-connectionstring.png) 78 | 79 | 1. Use the **az datamigration login-migration** command to create and start a database migration. 80 | 81 | ```azurecli 82 | az datamigration login-migration ` 83 | --src-sql-connection-str "data source=10.1.0.4,1433;user id=sqladmin;password=My`$upp3r`$ecret;initial catalog=master;TrustServerCertificate=True" ` 84 | --tgt-sql-connection-str "data source=.database.windows.net;user id=sqladmin;password=My`$upp3r`$ecret;initial catalog=master;TrustServerCertificate=True" ` 85 | --list-of-login "sqlpoc" "sqlpocapp" "sqlpocreport" ` 86 | --output-folder "C:\temp\output" 87 | ``` 88 | 89 | > [!WARNING] 90 | > 91 | > Change the **managed instance name** 92 | 93 | > [!TIP] 94 | > 95 | > Windows accounts are out of scope but if you want to learn how to migrate them, check out this [prerequisites]( 96 | 97 | ![sqlmi-login-migration](../../../media/sqlmi-login-migration-cli.png) 98 | 99 | 2. **Login migration at scale** using config file 100 | 101 | Learn more about [Migrate SQL Server logins](https://learn.microsoft.com/en-us/azure/dms/tutorial-login-migration-ads#configure-login-migration-settings) 102 | 103 | ## Page Navigator 104 | 105 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 106 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 107 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 108 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md: -------------------------------------------------------------------------------- 1 | # Offline migration for Azure SQL Managed Instance using Azure Storage using CLI 2 | 3 | Perform offline migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 *(Already installed)* 9 | - Azure CLI *(Already installed)* 10 | - Az datamigration extension 11 | - Azure storage account *(Already provisioned)* 12 | - Azure Data Studio *(Already installed)* 13 | - Azure SQL Migration extension for Azure Data Studio 14 | 15 | ## Getting Started 16 | 17 | > [!CAUTION] 18 | > 19 | > - **Connect to the Jump Box VM** 20 | > - VM name: **jb-migration** 21 | > - Use the credentials provided on the deploy page. 22 | 23 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 24 | 25 | 1. Install az datamigration extension if it isn't installed. 26 | 27 | ```azurecli 28 | az extension add --name datamigration 29 | ``` 30 | 31 | 2. Run the following to log in from your client using your default web browser 32 | 33 | ```azurecli 34 | az login 35 | ``` 36 | 37 | If you have more than one subscription, you can select a particular subscription. 38 | 39 | ```azurecli 40 | az account set --subscription 41 | ``` 42 | 43 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 44 | 45 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 46 | 47 | 3. Backup database 48 | 49 | Backups must be taken before starting the migration: 50 | - [Create SAS tokens for your storage containers](https://learn.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/create-sas-tokens?tabs=Containers) 51 | - [Create a SQL Server credential using a shared access signature](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#2---create-a-sql-server-credential-using-a-shared-access-signature) 52 | - [Database backup to URL](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#3---database-backup-to-url) 53 | 54 | The following T-SQL is an example that creates the credential to use a Shared Access Signature and creates a backup. 55 | 56 | ```sql 57 | USE master 58 | CREATE CREDENTIAL [https://storagemigration.blob.core.windows.net/migration] 59 | -- this name must match the container path, start with https and must not contain a forward slash at the end 60 | WITH IDENTITY='SHARED ACCESS SIGNATURE' 61 | -- this is a mandatory string and should not be changed 62 | , SECRET = 'XXXXXXX' 63 | -- this is the shared access signature key. Don't forget to remove the first character "?" 64 | GO 65 | 66 | -- Back up the full AdventureWorks2019 database to the container 67 | BACKUP DATABASE AdventureWorks2019 TO URL = 'https://storagemigration.blob.core.windows.net/migration/AdventureWorks2019.bak' 68 | WITH CHECKSUM 69 | ``` 70 | 71 | ### Start database migration 72 | 73 | > [!CAUTION] 74 | > 75 | > - **Connect to the Jump Box VM** 76 | > - VM name: **jb-migration** 77 | > - Use the credentials provided on the deploy page. 78 | 79 | Use the **az datamigration sql-managed-instance create** command to create and start a database migration. 80 | 81 | ```azurecli 82 | az datamigration sql-managed-instance create ` 83 | --source-location '{\"AzureBlob\":{\"storageAccountResourceId\":\"/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/\",\"accountKey\":\"\",\"blobContainerName\":\"migration\"}}' ` 84 | --migration-service "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/MySqlMigrationService" ` 85 | --scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 86 | --source-database-name "AdventureWorks2019" ` 87 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" password="My$upp3r$ecret" user-name="sqladmin" ` 88 | --target-db-name "AdventureWorks" ` 89 | --resource-group ` 90 | --managed-instance-name 91 | --offline-configuration last-backup-name=".bak" offline=true 92 | ``` 93 | 94 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 95 | 96 | ```azurecli 97 | az datamigration sql-managed-instance create ` 98 | --source-location '{\"AzureBlob\":{\"storageAccountResourceId\":\"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/storagepocmigration\",\"accountKey\":\"XXXXXX\",\"blobContainerName\":\"migration\"}}' ` 99 | --migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/MySqlMigrationService" ` 100 | --scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 101 | --source-database-name "AdventureWorks2019" ` 102 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" password="My$upp3r$ecret" user-name="sqladmin" ` 103 | --target-db-name "AdventureWorks" ` 104 | --resource-group oneclickpoc ` 105 | --managed-instance-name sqlmicsapocmigration 106 | --offline-configuration last-backup-name="AdventureWorks2019.bak" offline=true 107 | ``` 108 | 109 | > [!TIP] 110 | > 111 | > You should take all necessary backups. 112 | 113 | Learn more about using [CLI to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-to-sql-mi-blob.md#start-online-database-migration) 114 | 115 | ### Monitoring migration 116 | 117 | Use the **az datamigration sql-db show** command to monitor migration. 118 | 119 | 1. Basic migration details 120 | 121 | ```azurecli 122 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" 123 | ``` 124 | 125 | 2. Gets complete migration detail 126 | 127 | ```azurecli 128 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails 129 | ``` 130 | 131 | 3. *ProvisioningState* should be "**Creating**", "**Failed**" or "**Succeeded**" 132 | 133 | ```azurecli 134 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.provisioningState" 135 | ``` 136 | 137 | 4. *MigrationStatus* should be "**InProgress**", "**Canceling**", "**Failed**" or "**Succeeded**" 138 | 139 | ```azurecli 140 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.migrationStatus" 141 | ``` 142 | 143 | ## Migrating at scale 144 | 145 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/CLI/scripts/multiple%20databases) 146 | 147 | ## Page Navigator 148 | 149 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 150 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 151 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 152 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md: -------------------------------------------------------------------------------- 1 | # Offline migration for Azure SQL Managed Instance using Azure Storage using CLI 2 | 3 | Perform offline migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 *(Already installed)* 9 | - Azure CLI *(Already installed)* 10 | - Az datamigration extension 11 | - Azure storage account *(Already provisioned)* 12 | - Azure Data Studio *(Already installed)* 13 | - Azure SQL Migration extension for Azure Data Studio 14 | 15 | ## Getting Started 16 | 17 | > [!CAUTION] 18 | > 19 | > - **Connect to the Jump Box VM** 20 | > - VM name: **jb-migration** 21 | > - Use the credentials provided on the deploy page. 22 | 23 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 24 | 25 | 1. Install az datamigration extension if it isn't installed. 26 | 27 | ```azurecli 28 | az extension add --name datamigration 29 | ``` 30 | 31 | 2. Run the following to log in from your client using your default web browser 32 | 33 | ```azurecli 34 | az login 35 | ``` 36 | 37 | If you have more than one subscription, you can select a particular subscription. 38 | 39 | ```azurecli 40 | az account set --subscription 41 | ``` 42 | 43 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 44 | 45 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 46 | 47 | 3. Backup database 48 | 49 | ```sql 50 | USE master 51 | BACKUP DATABASE AdventureWorks2019 TO Disk = 'C:\temp\backup\AdventureWorks2019.bak' 52 | WITH CHECKSUM 53 | ``` 54 | 55 | ### Register Database Migration Service with self-hosted Integration Runtime 56 | 57 | 1. Use the **az datamigration sql-service list-auth-key** command to obtain AuthKeys. 58 | 59 | ```azurecli 60 | $AuthKey = az datamigration sql-service list-auth-key ` 61 | --resource-group "" ` 62 | --sql-migration-service-name "PoCMigrationService" ` 63 | --query "authKey1" 64 | ``` 65 | 66 | - The following example obtains the authKey: 67 | 68 | ```azurecli 69 | $AuthKey = az datamigration sql-service list-auth-key ` 70 | --resource-group "oneclickpoc" ` 71 | --sql-migration-service-name "PoCMigrationService" ` 72 | --query "authKey1" 73 | ``` 74 | 75 | 2. Change the PowerShell execution policy. 76 | 77 | ```azurecli 78 | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 79 | ``` 80 | 81 | 3. Use the **az datamigration register-integration-runtime** command to register the service on Integration Runtime. 82 | 83 | ```azurecli 84 | az datamigration register-integration-runtime --auth-key 85 | ``` 86 | 87 | The following example registers the service on Integration Runtime: 88 | 89 | ```azurecli 90 | az datamigration register-integration-runtime --auth-key $AuthKey 91 | ``` 92 | 93 | > [!WARNING] 94 | > 95 | > If you receive an error message saying: "RegisterIntegrationRuntime.ps1 cannot be loaded because running scripts is disabled on this system", please, run the following command and re-run the az command above. 96 | > 97 | > `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned` 98 | 99 | ### Start database migration 100 | 101 | > [!CAUTION] 102 | > 103 | > - **Connect to the Jump Box VM** 104 | > - VM name: **jb-migration** 105 | > - Use the credentials provided on the deploy page. 106 | 107 | Use the **az datamigration sql-managed-instance create** command to create and start a database migration. 108 | ```azurecli 109 | az datamigration sql-managed-instance create ` 110 | --source-location '{\"fileShare\":{\"path\":\"\\\\10.1.0.4\\SQLBackup\",\"password\":\"My$upp3r$ecret\",\"username\":\"10.1.0.4\\sqladmin\"}}' ` 111 | --target-location account-key="" storage-account-resource-id="/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" ` 112 | --migration-service "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 113 | --scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 114 | --source-database-name "AdventureWorks2019" ` 115 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" encrypt-connection=true trust-server-certificate=true password="My`$upp3r`$ecret" user-name="sqladmin" ` 116 | --target-db-name "AdventureWorks" ` 117 | --resource-group sqladmin ` 118 | --managed-instance-name ` 119 | --offline-configuration offline=true 120 | 121 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 122 | 123 | ```azurecli 124 | 125 | az datamigration sql-managed-instance create ` 126 | --source-location '{\"fileShare\":{\"path\":\"\\\\10.1.0.4\\SQLBackup\",\"password\":\"My`$upp3r`$ecret\",\"username\":\"10.1.0.4\\sqladmin\"}}' ` 127 | --target-location account-key="XXXXXXXX" storage-account-resource-id="/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/" ` 128 | --migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 129 | --scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 130 | --source-database-name "AdventureWorks2019" ` 131 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" encrypt-connection=true trust-server-certificate=true password="My`$upp3r`$ecret" user-name="sqladmin" ` 132 | --target-db-name "AdventureWorks" ` 133 | --resource-group sqladmin ` 134 | --managed-instance-name sqlmicsapocmigration ` 135 | --offline-configuration offline=true 136 | ``` 137 | 138 | > [!TIP] 139 | > 140 | > You should take all necessary backups. 141 | 142 | Learn more about using [CLI to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-to-sql-mi-blob.md#start-online-database-migration) 143 | 144 | ### Monitoring migration 145 | 146 | Use the **az datamigration sql-db show** command to monitor migration. 147 | 148 | 1. Basic migration details 149 | 150 | ```azurecli 151 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" 152 | ``` 153 | 154 | 2. Gets complete migration detail 155 | 156 | ```azurecli 157 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails 158 | ``` 159 | 160 | 3. *ProvisioningState* should be "**Creating**", "**Failed**" or "**Succeeded**" 161 | 162 | ```azurecli 163 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.provisioningState" 164 | ``` 165 | 166 | 4. *MigrationStatus* should be "**InProgress**", "**Canceling**", "**Failed**" or "**Succeeded**" 167 | 168 | ```azurecli 169 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.migrationStatus" 170 | ``` 171 | 172 | ## Migrating at scale 173 | 174 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/CLI/scripts/multiple%20databases) 175 | 176 | ## Page Navigator 177 | 178 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 179 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 180 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 181 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/CLI/azuresqlmi-online-migration-using-azure-storage-cli.md: -------------------------------------------------------------------------------- 1 | # Online migration for Azure SQL Managed Instance using Azure Storage using CLI 2 | 3 | Perform online migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 *(Already installed)* 9 | - Azure CLI *(Already installed)* 10 | - Az datamigration extension 11 | - Azure storage account *(Already provisioned)* 12 | - Azure Data Studio *(Already installed)* 13 | - Azure SQL Migration extension for Azure Data Studio 14 | 15 | ## Getting Started 16 | 17 | > [!CAUTION] 18 | > 19 | > - **Connect to the Jump Box VM** 20 | > - VM name: **jb-migration** 21 | > - Use the credentials provided on the deploy page. 22 | 23 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 24 | 25 | 1. Install az datamigration extension if it isn't installed. 26 | 27 | ```azurecli 28 | az extension add --name datamigration 29 | ``` 30 | 31 | 2. Run the following to log in from your client using your default web browser 32 | 33 | ```azurecli 34 | az login 35 | ``` 36 | 37 | If you have more than one subscription, you can select a particular subscription. 38 | 39 | ```azurecli 40 | az account set --subscription 41 | ``` 42 | 43 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 44 | 45 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 46 | 47 | 3. Backup database 48 | 49 | Backups must be taken before starting the migration: 50 | - [Create SAS tokens for your storage containers](https://learn.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/create-sas-tokens?tabs=Containers) 51 | - [Create a SQL Server credential using a shared access signature](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#2---create-a-sql-server-credential-using-a-shared-access-signature) 52 | - [Database backup to URL](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#3---database-backup-to-url) 53 | 54 | The following T-SQL is an example that creates the credential to use a Shared Access Signature and creates a backup. 55 | 56 | ```sql 57 | USE master 58 | CREATE CREDENTIAL [https://storagemigration.blob.core.windows.net/migration] 59 | -- this name must match the container path, start with https and must not contain a forward slash at the end 60 | WITH IDENTITY='SHARED ACCESS SIGNATURE' 61 | -- this is a mandatory string and should not be changed 62 | , SECRET = 'XXXXXXX' 63 | -- this is the shared access signature key. Don't forget to remove the first character "?" 64 | GO 65 | 66 | -- Back up the full AdventureWorks2019 database to the container 67 | BACKUP DATABASE AdventureWorks2019 TO URL = 'https://storagemigration.blob.core.windows.net/migration/AdventureWorks2019.bak' 68 | WITH CHECKSUM 69 | ``` 70 | 71 | ### Start database migration 72 | 73 | > [!CAUTION] 74 | > 75 | > - **Connect to the Jump Box VM** 76 | > - VM name: **jb-migration** 77 | > - Use the credentials provided on the deploy page. 78 | 79 | Use the **az datamigration sql-managed-instance create** command to create and start a database migration. 80 | 81 | ```azurecli 82 | az datamigration sql-managed-instance create ` 83 | --source-location '{\"AzureBlob\":{\"storageAccountResourceId\":\"/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/\",\"accountKey\":\"\",\"blobContainerName\":\"migration\"}}' ` 84 | --migration-service "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/MySqlMigrationService" ` 85 | --scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 86 | --source-database-name "AdventureWorks2019" ` 87 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" password="My$upp3r$ecret" user-name="sqladmin" ` 88 | --target-db-name "AdventureWorks" ` 89 | --resource-group ` 90 | --managed-instance-name 91 | ``` 92 | 93 | > [!TIP] 94 | > 95 | > You should take all necessary backups. 96 | 97 | Learn more about using [CLI to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-to-sql-mi-blob.md#start-online-database-migration) 98 | 99 | ### Monitoring migration 100 | 101 | Use the **az datamigration sql-db show** command to monitor migration. 102 | 103 | 1. Basic migration details 104 | 105 | ```azurecli 106 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" 107 | ``` 108 | 109 | 2. Gets complete migration detail 110 | 111 | ```azurecli 112 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails 113 | ``` 114 | 115 | 3. *ProvisioningState* should be "**Creating**", "**Failed**" or "**Succeeded**" 116 | 117 | ```azurecli 118 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.provisioningState" 119 | ``` 120 | 121 | 4. *MigrationStatus* should be "**InProgress**", "**Canceling**", "**Failed**" or "**Succeeded**" 122 | 123 | ```azurecli 124 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.migrationStatus" 125 | 126 | ### Cutover for online migration 127 | 128 | Use the **az datamigration sql-managed-instance cutover** command to perform cutover. 129 | 130 | 1. Obtain the MigrationOperationId 131 | 132 | ```azurecli 133 | $migOpId = az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.migrationOperationId" 134 | ``` 135 | 136 | 2. Perform Cutover 137 | 138 | ```azurecli 139 | az datamigration sql-managed-instance cutover --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks2019" --migration-operation-id $migOpId 140 | ``` 141 | 142 | ## Migrating at scale 143 | 144 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/CLI/scripts/multiple%20databases) 145 | 146 | ## Page Navigator 147 | 148 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 149 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 150 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 151 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/CLI/azuresqlmi-online-migration-using-file-share-cli.md: -------------------------------------------------------------------------------- 1 | # Online migration for Azure SQL Managed Instance using File Share using CLI 2 | 3 | Perform offline migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 *(Already installed)* 9 | - Azure CLI *(Already installed)* 10 | - Az datamigration extension 11 | - Azure storage account *(Already provisioned)* 12 | - Azure Data Studio *(Already installed)* 13 | - Azure SQL Migration extension for Azure Data Studio 14 | 15 | ## Getting Started 16 | 17 | > [!CAUTION] 18 | > 19 | > - **Connect to the Jump Box VM** 20 | > - VM name: **jb-migration** 21 | > - Use the credentials provided on the deploy page. 22 | 23 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 24 | 25 | 1. Install az datamigration extension if it isn't installed. 26 | 27 | ```azurecli 28 | az extension add --name datamigration 29 | ``` 30 | 31 | 2. Run the following to log in from your client using your default web browser 32 | 33 | ```azurecli 34 | az login 35 | ``` 36 | 37 | If you have more than one subscription, you can select a particular subscription. 38 | 39 | ```azurecli 40 | az account set --subscription 41 | ``` 42 | 43 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 44 | 45 | In addition, the Azure CLI command [az datamigration](https://learn.microsoft.com/en-us/cli/azure/datamigration?view=azure-cli-latest) can be used to manage data migration at scale. 46 | 47 | 3. Backup database 48 | 49 | ```sql 50 | USE master 51 | BACKUP DATABASE AdventureWorks2019 TO Disk = 'C:\temp\backup\AdventureWorks2019.bak' 52 | WITH CHECKSUM 53 | ``` 54 | 55 | ### Register Database Migration Service with self-hosted Integration Runtime 56 | 57 | 1. Use the **az datamigration sql-service list-auth-key** command to obtain AuthKeys. 58 | 59 | ```azurecli 60 | $AuthKey = az datamigration sql-service list-auth-key ` 61 | --resource-group "" ` 62 | --sql-migration-service-name "PoCMigrationService" ` 63 | --query "authKey1" 64 | ``` 65 | 66 | - The following example obtains the authKey: 67 | 68 | ```azurecli 69 | $AuthKey = az datamigration sql-service list-auth-key ` 70 | --resource-group "oneclickpoc" ` 71 | --sql-migration-service-name "PoCMigrationService" ` 72 | --query "authKey1" 73 | ``` 74 | 75 | 2. Change the PowerShell execution policy. 76 | 77 | ```azurecli 78 | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 79 | ``` 80 | 81 | 3. Use the **az datamigration register-integration-runtime** command to register the service on Integration Runtime. 82 | 83 | ```azurecli 84 | az datamigration register-integration-runtime --auth-key 85 | ``` 86 | 87 | The following example registers the service on Integration Runtime: 88 | 89 | ```azurecli 90 | az datamigration register-integration-runtime --auth-key $AuthKey 91 | ``` 92 | 93 | > [!WARNING] 94 | > 95 | > If you receive an error message saying: "RegisterIntegrationRuntime.ps1 cannot be loaded because running scripts is disabled on this system", please, run the following command and re-run the az command above. 96 | > 97 | > `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned` 98 | 99 | ### Start database migration 100 | 101 | > [!CAUTION] 102 | > 103 | > - **Connect to the Jump Box VM** 104 | > - VM name: **jb-migration** 105 | > - Use the credentials provided on the deploy page. 106 | 107 | Use the **az datamigration sql-managed-instance create** command to create and start a database migration. 108 | ```azurecli 109 | az datamigration sql-managed-instance create ` 110 | --source-location '{\"fileShare\":{\"path\":\"\\\\10.1.0.4\\SQLBackup\",\"password\":\"My$upp3r$ecret\",\"username\":\"10.1.0.4\\sqladmin\"}}' ` 111 | --target-location account-key="" storage-account-resource-id="/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" ` 112 | --migration-service "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 113 | --scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 114 | --source-database-name "AdventureWorks2019" ` 115 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" encrypt-connection=true trust-server-certificate=true password="My`$upp3r`$ecret" user-name="sqladmin" ` 116 | --target-db-name "AdventureWorks" ` 117 | --resource-group sqladmin ` 118 | --managed-instance-name ` 119 | 120 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 121 | 122 | ```azurecli 123 | 124 | az datamigration sql-managed-instance create ` 125 | --source-location '{\"fileShare\":{\"path\":\"\\\\10.1.0.4\\SQLBackup\",\"password\":\"My`$upp3r`$ecret\",\"username\":\"10.1.0.4\\sqladmin\"}}' ` 126 | --target-location account-key="XXXXXXXX" storage-account-resource-id="/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/" ` 127 | --migration-service "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 128 | --scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 129 | --source-database-name "AdventureWorks2019" ` 130 | --source-sql-connection authentication="SqlAuthentication" data-source="10.1.0.4" encrypt-connection=true trust-server-certificate=true password="My`$upp3r`$ecret" user-name="sqladmin" ` 131 | --target-db-name "AdventureWorks" ` 132 | --resource-group sqladmin ` 133 | --managed-instance-name sqlmicsapocmigration ` 134 | ``` 135 | 136 | > [!TIP] 137 | > 138 | > You should take all necessary backups. 139 | 140 | Learn more about using [CLI to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/CLI/sql-server-to-sql-mi-blob.md#start-online-database-migration) 141 | 142 | ### Monitoring migration 143 | 144 | Use the **az datamigration sql-db show** command to monitor migration. 145 | 146 | 1. Basic migration details 147 | 148 | ```azurecli 149 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" 150 | ``` 151 | 152 | 2. Gets complete migration detail 153 | 154 | ```azurecli 155 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails 156 | ``` 157 | 158 | 3. *ProvisioningState* should be "**Creating**", "**Failed**" or "**Succeeded**" 159 | 160 | ```azurecli 161 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.provisioningState" 162 | ``` 163 | 164 | 4. *MigrationStatus* should be "**InProgress**", "**Canceling**", "**Failed**" or "**Succeeded**" 165 | 166 | ```azurecli 167 | az datamigration sql-managed-instance show --managed-instance-name "" --resource-group "" --target-db-name "AdventureWorks" --expand=MigrationStatusDetails --query "properties.migrationStatus" 168 | ``` 169 | 170 | ## Migrating at scale 171 | 172 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/CLI/scripts/multiple%20databases) 173 | 174 | ## Page Navigator 175 | 176 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 177 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 178 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 179 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/PowerShell/azuresqlmi-login-migration-using-ps.md: -------------------------------------------------------------------------------- 1 | # Login migration for Azure SQL Managed Instance using PowerShell 2 | 3 | Perform a login migration of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Managed Instance using the Azure SQL Migration extension. 4 | 5 | ## Migration using Azure storage 6 | 7 | ### Prerequisites 8 | 9 | - SQL Server with Windows authentication or SQL authentication access 10 | - .Net Core 3.1 (Already installed) 11 | - Az.DataMigration PowerShell module 12 | 13 | ## Getting Started 14 | 15 | > [!CAUTION] 16 | > 17 | > - **Connect to the Jump Box VM** 18 | > - VM name: **jb-migration** 19 | > - Use the credentials provided on the deploy page. 20 | 21 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 22 | 23 | 1. Run the following to log in from your client using your default web browser if you are not logged in. 24 | 25 | ```powershell 26 | Connect-AzAccount -Subscription 27 | ``` 28 | 29 | If you have more than one subscription, you can select a particular subscription. 30 | 31 | ```powershell 32 | Set-AzContext -SubscriptionId 33 | ``` 34 | 35 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 36 | 37 | In addition, the PowerShell command [Data Migration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0#data-migrationt) can be used to manage data migration at scale. 38 | 39 | 2. Verify SQL Logins to be migrated 40 | 41 | Open the Azure Data Studio, connect to the *Azure SQL VM* (**10.1.0.4**) using the "**sqladmin**" user and password and run the following T-SQL statement to see all SQL Logins. 42 | 43 | ```sql 44 | SELECT 45 | sp.name AS server_login_name, 46 | dp.name AS database_user_name, 47 | sp.type_desc, 48 | sp.is_disabled 49 | FROM sys.server_principals AS sp 50 | INNER JOIN WideWorldImportersDW.sys.database_principals AS dp ON SP.sid = DP.sid 51 | ``` 52 | 53 | ### Start login migration 54 | 55 | > [!CAUTION] 56 | > 57 | > - **Connect to the Jump Box VM** 58 | > - VM name: **jb-migration** 59 | > - Use the credentials provided on the deploy page. 60 | 61 | At this point you will need to get the Azure SQL MI name. [Get server connection information](https://learn.microsoft.com/en-us/azure/azure-sql/database/connect-query-content-reference-guide?view=azuresql#get-server-connection-information) 62 | 63 | ![sqlmi-connectionstring](../../../media/sqlmi-connectionstring.png) 64 | 65 | 1. Use the **New-AzDataMigrationLoginsMigration** command to create and start a database migration. 66 | 67 | ```powershell 68 | New-AzDataMigrationLoginsMigration ` 69 | -SourceSqlConnectionString "data source=10.1.0.4,1433;user id=sqladmin;password=My`$upp3r`$ecret;initial catalog=master;TrustServerCertificate=True" ` 70 | -TargetSqlConnectionString "data source=.database.windows.net;user id=sqladmin;password=My`$upp3r`$ecret;initial catalog=master;TrustServerCertificate=True" ` 71 | -ListOfLogin "sqlpoc" "sqlpocapp" "sqlpocreport" ` 72 | -OutputFolder "C:\temp\output" 73 | ``` 74 | 75 | > [!WARNING] 76 | > 77 | > Change the **managed instance name** 78 | 79 | > [!TIP] 80 | > 81 | > Windows accounts are out of scope but if you want to learn how to migrate them, check out this [prerequisites]( 82 | 83 | ![sqlmi-login-migration](../../../media/sqlmi-login-migration-cli.png) 84 | 85 | 2. **Login migration at scale** using config file 86 | 87 | Learn more about [Migrate SQL Server logins](https://learn.microsoft.com/en-us/azure/dms/tutorial-login-migration-ads#configure-login-migration-settings) 88 | 89 | ## Page Navigator 90 | 91 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 92 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 93 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 94 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-azure-storage-ps.md: -------------------------------------------------------------------------------- 1 | # Offline migration for Azure SQL Managed Instance using Azure Storage using PowerShell 2 | 3 | Perform offline migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 (Already installed) 9 | - Az.DataMigration PowerShell module 10 | 11 | ## Getting Started 12 | 13 | > [!CAUTION] 14 | > 15 | > - **Connect to the Jump Box VM** 16 | > - VM name: **jb-migration** 17 | > - Use the credentials provided on the deploy page. 18 | 19 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 20 | 21 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 22 | 23 | In addition, the Azure PowerShell command [Az.DataMigration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0) can be used to manage data migration at scale. 24 | 25 | 1. Run the following to log in from your client using your default web browser if you are not logged in. 26 | 27 | ```powershell 28 | Connect-AzAccount -Subscription 29 | ``` 30 | 31 | If you have more than one subscription, you can select a particular subscription. 32 | 33 | ```powershell 34 | Set-AzContext -SubscriptionId 35 | ``` 36 | 37 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 38 | 39 | In addition, the PowerShell command [Data Migration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0#data-migrationt) can be used to manage data migration at scale. 40 | 41 | 2. Backup database 42 | 43 | Backups must be taken before starting the migration: 44 | - [Create SAS tokens for your storage containers](https://learn.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/create-sas-tokens?tabs=Containers) 45 | - [Create a SQL Server credential using a shared access signature](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#2---create-a-sql-server-credential-using-a-shared-access-signature) 46 | - [Database backup to URL](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#3---database-backup-to-url) 47 | 48 | The following T-SQL is an example that creates the credential to use a Shared Access Signature and creates a backup. 49 | 50 | ```sql 51 | USE master 52 | CREATE CREDENTIAL [https://storagemigration.blob.core.windows.net/migration] 53 | -- this name must match the container path, start with https and must not contain a forward slash at the end 54 | WITH IDENTITY='SHARED ACCESS SIGNATURE' 55 | -- this is a mandatory string and should not be changed 56 | , SECRET = 'XXXXXXX' 57 | -- this is the shared access signature key. Don't forget to remove the first character "?" 58 | GO 59 | 60 | -- Back up the full AdventureWorks2019 database to the container 61 | BACKUP DATABASE AdventureWorks2019 TO URL = 'https://storagemigration.blob.core.windows.net/migration/AdventureWorks2019.bak' 62 | WITH CHECKSUM 63 | ``` 64 | 65 | ### Start database migration 66 | 67 | > [!CAUTION] 68 | > 69 | > - **Connect to the Jump Box VM** 70 | > - VM name: **jb-migration** 71 | > - Use the credentials provided on the deploy page. 72 | 73 | 1. Convert the passwords to secure string 74 | 75 | ```powershell 76 | $sourcePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 77 | ``` 78 | 79 | 2. Use the **New-AzDataMigrationToSqlManagedInstance** command to create and start a database migration. 80 | 81 | ```powershell 82 | New-AzDataMigrationToSqlManagedInstance ` 83 | -ResourceGroupName ` 84 | -ManagedInstanceName ` 85 | -TargetDbName "AdventureWorks" ` 86 | -Kind "SqlMI" ` 87 | -Scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 88 | -MigrationService "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 89 | -AzureBlobStorageAccountResourceId "/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" ` 90 | -AzureBlobAccountKey "" ` 91 | -AzureBlobContainerName "migration" ` 92 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 93 | -SourceSqlConnectionDataSource "10.1.0.4" ` 94 | -SourceSqlConnectionUserName "sqladmin" ` 95 | -SourceSqlConnectionPassword $sourcePassword ` 96 | -SourceDatabaseName "AdventureWorks2019" ` 97 | -Offline ` 98 | -OfflineConfigurationLastBackupName ".bak" 99 | ``` 100 | 101 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 102 | 103 | ```powershell 104 | New-AzDataMigrationToSqlManagedInstance ` 105 | -ResourceGroupName oneclickpoc ` 106 | -ManagedInstanceName sqlmicsapocmigration ` 107 | -TargetDbName "AdventureWorks" ` 108 | -Kind "SqlMI" ` 109 | -Scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 110 | -MigrationService "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 111 | -AzureBlobStorageAccountResourceId "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/storagepocmigration" ` 112 | -AzureBlobAccountKey "XXXXXX" ` 113 | -AzureBlobContainerName "migration" ` 114 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 115 | -SourceSqlConnectionDataSource "10.1.0.4" ` 116 | -SourceSqlConnectionUserName "sqladmin" ` 117 | -SourceSqlConnectionPassword $sourcePassword ` 118 | -SourceDatabaseName "AdventureWorks2019" ` 119 | -Offline ` 120 | -OfflineConfigurationLastBackupName "AdventureWorks2019.bak" 121 | ``` 122 | 123 | > [!TIP] 124 | > 125 | > You should take all necessary backups. 126 | 127 | Learn more about using [Powershell to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-to-sql-mi-blob.md#start-online-database-migration) 128 | 129 | ### Monitoring migration 130 | 131 | Use the **Get-AzDataMigrationToSqlManagedInstance** command to monitor migration. 132 | 133 | 1. Get complete migration details 134 | 135 | ```powershell 136 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 137 | -ResourceGroupName ` 138 | -SqlDbInstanceName ` 139 | -TargetDbName AdventureWorks ` 140 | -Expand MigrationStatusDetails 141 | 142 | $monitoringMigration 143 | ``` 144 | 145 | The following example brings complete details 146 | 147 | ```powershell 148 | 149 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 150 | -ResourceGroupName oneclickpoc ` 151 | -SqlDbInstanceName sqlservercsapocmigration ` 152 | -TargetDbName AdventureWorks ` 153 | -Expand MigrationStatusDetails 154 | 155 | $monitoringMigration 156 | 157 | ``` 158 | 159 | 2. ProvisioningState should be **Creating, Failed, or Succeeded** 160 | 161 | ```powershell 162 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 163 | -ResourceGroupName ` 164 | -SqlDbInstanceName ` 165 | -TargetDbName AdventureWorks ` 166 | -Expand MigrationStatusDetails 167 | 168 | $monitoringMigration.ProvisioningState | Format-List 169 | ``` 170 | 171 | The following example brings complete details 172 | 173 | ```powershell 174 | 175 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 176 | -ResourceGroupName oneclickpoc ` 177 | -SqlDbInstanceName sqlservercsapocmigration ` 178 | -TargetDbName AdventureWorks ` 179 | -Expand MigrationStatusDetails 180 | 181 | $monitoringMigration.ProvisioningState | Format-List 182 | 183 | ``` 184 | 185 | 3. MigrationStatus should be **InProgress, Canceling, Failed, or Succeeded** 186 | 187 | ```powershell 188 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 189 | -ResourceGroupName ` 190 | -SqlDbInstanceName ` 191 | -TargetDbName AdventureWorks ` 192 | -Expand MigrationStatusDetails 193 | 194 | $monitoringMigration.MigrationStatus | Format-List 195 | ``` 196 | 197 | The following example brings complete details 198 | 199 | ```powershell 200 | 201 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 202 | -ResourceGroupName oneclickpoc ` 203 | -SqlDbInstanceName sqlservercsapocmigration ` 204 | -TargetDbName AdventureWorks ` 205 | -Expand MigrationStatusDetails 206 | 207 | $monitoringMigration.MigrationStatus | Format-List 208 | ``` 209 | 210 | You can also use the Azure Portal to monitor migration. 211 | 212 | ![migration succeeded](/media/sqldb-migration-succeeded.png) 213 | 214 | ## Migrating at scale 215 | 216 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/PowerShell/scripts/multiple%20databases) 217 | 218 | ## Page Navigator 219 | 220 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 221 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 222 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 223 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md: -------------------------------------------------------------------------------- 1 | # Offline migration for Azure SQL Managed Instance using File Share using PowerShell 2 | 3 | Perform offline migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 (Already installed) 9 | - Az.DataMigration PowerShell module 10 | 11 | ## Getting Started 12 | 13 | > [!CAUTION] 14 | > 15 | > - **Connect to the Jump Box VM** 16 | > - VM name: **jb-migration** 17 | > - Use the credentials provided on the deploy page. 18 | 19 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 20 | 21 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 22 | 23 | In addition, the Azure PowerShell command [Az.DataMigration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0) can be used to manage data migration at scale. 24 | 25 | 1. Run the following to log in from your client using your default web browser if you are not logged in. 26 | 27 | ```powershell 28 | Connect-AzAccount -Subscription 29 | ``` 30 | 31 | If you have more than one subscription, you can select a particular subscription. 32 | 33 | ```powershell 34 | Set-AzContext -SubscriptionId 35 | ``` 36 | 37 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 38 | 39 | In addition, the PowerShell command [Data Migration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0#data-migrationt) can be used to manage data migration at scale. 40 | 41 | 2. Backup database 42 | 43 | ```sql 44 | USE master 45 | BACKUP DATABASE AdventureWorks2019 TO Disk = 'C:\temp\backup\AdventureWorks2019.bak' 46 | WITH CHECKSUM 47 | ``` 48 | 49 | ### Register Database Migration Service with self-hosted Integration Runtime 50 | 51 | 1. Use the **Get-AzDataMigrationSqlServiceAuthKey** command to obtain AuthKeys. 52 | 53 | ```powershell 54 | $AuthKeys = Get-AzDataMigrationSqlServiceAuthKey ` 55 | -ResourceGroupName "" ` 56 | -SqlMigrationServiceName "PoCMigrationService" 57 | ``` 58 | 59 | - The following example obtains the authKey: 60 | 61 | ```powershell 62 | $AuthKeys = Get-AzDataMigrationSqlServiceAuthKey ` 63 | -ResourceGroupName "oneclickpoc" ` 64 | -SqlMigrationServiceName "PoCMigrationService" 65 | ``` 66 | 67 | 2. Change the PowerShell execution policy. 68 | 69 | ```powershell 70 | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 71 | ``` 72 | 73 | 3. Use the **az datamigration register-integration-runtime** command to register the service on Integration Runtime. 74 | 75 | ```powershell 76 | Register-AzDataMigrationIntegrationRuntime ` 77 | -AuthKey ` 78 | ``` 79 | 80 | The following example registers the service on Integration Runtime: 81 | 82 | ```powershell 83 | Register-AzDataMigrationIntegrationRuntime ` 84 | -AuthKey $AuthKeys.AuthKey1 ` 85 | ``` 86 | 87 | > [!WARNING] 88 | > If you receive an error message saying: "RegisterIntegrationRuntime.ps1 cannot be loaded because running scripts is disabled on this system", please, run the following command and re-run the PowerShell command above. 89 | > 90 | > `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned` 91 | 92 | ### Start database migration 93 | 94 | > [!CAUTION] 95 | > 96 | > - **Connect to the Jump Box VM** 97 | > - VM name: **jb-migration** 98 | > - Use the credentials provided on the deploy page. 99 | 100 | 1. Convert the passwords to secure string 101 | 102 | ```powershell 103 | $sourcePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 104 | $sourceFileSharePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 105 | 106 | ``` 107 | 108 | 2. Use the **New-AzDataMigrationToSqlManagedInstance** command to create and start a database migration. 109 | 110 | ```powershell 111 | New-AzDataMigrationToSqlManagedInstance ` 112 | -ResourceGroupName ` 113 | -ManagedInstanceName ` 114 | -TargetDbName "AdventureWorks" ` 115 | -Kind "SqlMI" ` 116 | -Scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 117 | -MigrationService "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 118 | -StorageAccountResourceId "/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" ` 119 | -StorageAccountKey "" ` 120 | -FileSharePath "\\sqlvm-001\SQLBackup" ` 121 | -FileShareUsername "sqlvm-001\sqladmin" ` 122 | -FileSharePassword $sourceFileSharePassword ` 123 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 124 | -SourceSqlConnectionDataSource "10.1.0.4" ` 125 | -SourceSqlConnectionUserName "sqladmin" ` 126 | -SourceSqlConnectionPassword $sourcePassword ` 127 | -SourceDatabaseName "AdventureWorks2019" ` 128 | -Offline 129 | ``` 130 | 131 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 132 | 133 | ```powershell 134 | New-AzDataMigrationToSqlManagedInstance ` 135 | -ResourceGroupName oneclickpoc ` 136 | -ManagedInstanceName sqlmicsapocmigration ` 137 | -TargetDbName "AdventureWorks" ` 138 | -Kind "SqlMI" ` 139 | -Scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 140 | -MigrationService "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 141 | -StorageAccountResourceId "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/storagepocmigration" ` 142 | -StorageAccountKey "XXXXXXXX" ` 143 | -FileSharePath "\\10.1.0.4\SQLBackup" ` 144 | -FileShareUsername "10.1.0.4\sqladmin" ` 145 | -FileSharePassword $sourceFileSharePassword ` 146 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 147 | -SourceSqlConnectionDataSource "10.1.0.4" ` 148 | -SourceSqlConnectionUserName "sqladmin" ` 149 | -SourceSqlConnectionPassword $sourcePassword ` 150 | -SourceDatabaseName "AdventureWorks2019" ` 151 | -Offline 152 | ``` 153 | 154 | > [!TIP] 155 | > 156 | > You should take all necessary backups. 157 | 158 | Learn more about using [Powershell to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-to-sql-mi-blob.md#start-online-database-migration) 159 | 160 | ### Monitoring migration 161 | 162 | Use the **Get-AzDataMigrationToSqlManagedInstance** command to monitor migration. 163 | 164 | 1. Get complete migration details 165 | 166 | ```powershell 167 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 168 | -ResourceGroupName ` 169 | -SqlDbInstanceName ` 170 | -TargetDbName AdventureWorks ` 171 | -Expand MigrationStatusDetails 172 | 173 | $monitoringMigration 174 | ``` 175 | 176 | The following example brings complete details 177 | 178 | ```powershell 179 | 180 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 181 | -ResourceGroupName oneclickpoc ` 182 | -SqlDbInstanceName sqlservercsapocmigration ` 183 | -TargetDbName AdventureWorks ` 184 | -Expand MigrationStatusDetails 185 | 186 | $monitoringMigration 187 | 188 | ``` 189 | 190 | 2. ProvisioningState should be **Creating, Failed, or Succeeded** 191 | 192 | ```powershell 193 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 194 | -ResourceGroupName ` 195 | -SqlDbInstanceName ` 196 | -TargetDbName AdventureWorks ` 197 | -Expand MigrationStatusDetails 198 | 199 | $monitoringMigration.ProvisioningState | Format-List 200 | ``` 201 | 202 | The following example brings complete details 203 | 204 | ```powershell 205 | 206 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 207 | -ResourceGroupName oneclickpoc ` 208 | -SqlDbInstanceName sqlservercsapocmigration ` 209 | -TargetDbName AdventureWorks ` 210 | -Expand MigrationStatusDetails 211 | 212 | $monitoringMigration.ProvisioningState | Format-List 213 | 214 | ``` 215 | 216 | 3. MigrationStatus should be **InProgress, Canceling, Failed, or Succeeded** 217 | 218 | ```powershell 219 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 220 | -ResourceGroupName ` 221 | -SqlDbInstanceName ` 222 | -TargetDbName AdventureWorks ` 223 | -Expand MigrationStatusDetails 224 | 225 | $monitoringMigration.MigrationStatus | Format-List 226 | ``` 227 | 228 | The following example brings complete details 229 | 230 | ```powershell 231 | 232 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 233 | -ResourceGroupName oneclickpoc ` 234 | -SqlDbInstanceName sqlservercsapocmigration ` 235 | -TargetDbName AdventureWorks ` 236 | -Expand MigrationStatusDetails 237 | 238 | $monitoringMigration.MigrationStatus | Format-List 239 | ``` 240 | 241 | You can also use the Azure Portal to monitor migration. 242 | 243 | ![migration succeeded](/media/sqldb-migration-succeeded.png) 244 | 245 | ## Migrating at scale 246 | 247 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/PowerShell/scripts/multiple%20databases) 248 | 249 | ## Page Navigator 250 | 251 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 252 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 253 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 254 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/PowerShell/azuresqlmi-online-migration-using-azure-storage-ps.md: -------------------------------------------------------------------------------- 1 | # Online migration for Azure SQL Managed Instance using Azure Storage using PowerShell 2 | 3 | Perform online migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 (Already installed) 9 | - Az.DataMigration PowerShell module 10 | 11 | ## Getting Started 12 | 13 | > [!CAUTION] 14 | > 15 | > - **Connect to the Jump Box VM** 16 | > - VM name: **jb-migration** 17 | > - Use the credentials provided on the deploy page. 18 | 19 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 20 | 21 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 22 | 23 | In addition, the Azure PowerShell command [Az.DataMigration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0) can be used to manage data migration at scale. 24 | 25 | 1. Run the following to log in from your client using your default web browser if you are not logged in. 26 | 27 | ```powershell 28 | Connect-AzAccount -Subscription 29 | ``` 30 | 31 | If you have more than one subscription, you can select a particular subscription. 32 | 33 | ```powershell 34 | Set-AzContext -SubscriptionId 35 | ``` 36 | 37 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 38 | 39 | In addition, the PowerShell command [Data Migration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0#data-migrationt) can be used to manage data migration at scale. 40 | 41 | 2. Backup database 42 | 43 | Backups must be taken before starting the migration: 44 | - [Create SAS tokens for your storage containers](https://learn.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/create-sas-tokens?tabs=Containers) 45 | - [Create a SQL Server credential using a shared access signature](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#2---create-a-sql-server-credential-using-a-shared-access-signature) 46 | - [Database backup to URL](https://learn.microsoft.com/en-us/sql/relational-databases/tutorial-use-azure-blob-storage-service-with-sql-server-2016?view=sql-server-ver16#3---database-backup-to-url) 47 | 48 | The following T-SQL is an example that creates the credential to use a Shared Access Signature and creates a backup. 49 | 50 | ```sql 51 | USE master 52 | CREATE CREDENTIAL [https://storagemigration.blob.core.windows.net/migration] 53 | -- this name must match the container path, start with https and must not contain a forward slash at the end 54 | WITH IDENTITY='SHARED ACCESS SIGNATURE' 55 | -- this is a mandatory string and should not be changed 56 | , SECRET = 'XXXXXXX' 57 | -- this is the shared access signature key. Don't forget to remove the first character "?" 58 | GO 59 | 60 | -- Back up the full AdventureWorks2019 database to the container 61 | BACKUP DATABASE AdventureWorks2019 TO URL = 'https://storagemigration.blob.core.windows.net/migration/AdventureWorks2019.bak' 62 | WITH CHECKSUM 63 | ``` 64 | 65 | ### Start database migration 66 | 67 | > [!CAUTION] 68 | > 69 | > - **Connect to the Jump Box VM** 70 | > - VM name: **jb-migration** 71 | > - Use the credentials provided on the deploy page. 72 | 73 | 1. Convert the passwords to secure string 74 | 75 | ```powershell 76 | $sourcePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 77 | ``` 78 | 79 | 2. Use the **New-AzDataMigrationToSqlManagedInstance** command to create and start a database migration. 80 | 81 | ```powershell 82 | New-AzDataMigrationToSqlManagedInstance ` 83 | -ResourceGroupName ` 84 | -ManagedInstanceName ` 85 | -TargetDbName "AdventureWorks" ` 86 | -Kind "SqlMI" ` 87 | -Scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 88 | -MigrationService "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 89 | -AzureBlobStorageAccountResourceId "/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" ` 90 | -AzureBlobAccountKey "" ` 91 | -AzureBlobContainerName "migration" ` 92 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 93 | -SourceSqlConnectionDataSource "10.1.0.4" ` 94 | -SourceSqlConnectionUserName "sqladmin" ` 95 | -SourceSqlConnectionPassword $sourcePassword ` 96 | -SourceDatabaseName "AdventureWorks2019" 97 | ``` 98 | 99 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 100 | 101 | ```powershell 102 | New-AzDataMigrationToSqlManagedInstance ` 103 | -ResourceGroupName oneclickpoc ` 104 | -ManagedInstanceName sqlmicsapocmigration ` 105 | -TargetDbName "AdventureWorks" ` 106 | -Kind "SqlMI" ` 107 | -Scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 108 | -MigrationService "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 109 | -AzureBlobStorageAccountResourceId "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/storagepocmigration" ` 110 | -AzureBlobAccountKey "XXXXXX" ` 111 | -AzureBlobContainerName "migration" ` 112 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 113 | -SourceSqlConnectionDataSource "10.1.0.4" ` 114 | -SourceSqlConnectionUserName "sqladmin" ` 115 | -SourceSqlConnectionPassword $sourcePassword ` 116 | -SourceDatabaseName "AdventureWorks2019" ` 117 | ``` 118 | 119 | > [!TIP] 120 | > 121 | > You should take all necessary backups. 122 | 123 | Learn more about using [Powershell to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-to-sql-mi-blob.md#start-online-database-migration) 124 | 125 | ### Monitoring migration 126 | 127 | Use the **Get-AzDataMigrationToSqlManagedInstance** command to monitor migration. 128 | 129 | 1. Get complete migration details 130 | 131 | ```powershell 132 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 133 | -ResourceGroupName ` 134 | -SqlDbInstanceName ` 135 | -TargetDbName AdventureWorks ` 136 | -Expand MigrationStatusDetails 137 | 138 | $monitoringMigration 139 | ``` 140 | 141 | The following example brings complete details 142 | 143 | ```powershell 144 | 145 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 146 | -ResourceGroupName oneclickpoc ` 147 | -SqlDbInstanceName sqlservercsapocmigration ` 148 | -TargetDbName AdventureWorks ` 149 | -Expand MigrationStatusDetails 150 | 151 | $monitoringMigration 152 | 153 | ``` 154 | 155 | 2. ProvisioningState should be **Creating, Failed, or Succeeded** 156 | 157 | ```powershell 158 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 159 | -ResourceGroupName ` 160 | -SqlDbInstanceName ` 161 | -TargetDbName AdventureWorks ` 162 | -Expand MigrationStatusDetails 163 | 164 | $monitoringMigration.ProvisioningState | Format-List 165 | ``` 166 | 167 | The following example brings complete details 168 | 169 | ```powershell 170 | 171 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 172 | -ResourceGroupName oneclickpoc ` 173 | -SqlDbInstanceName sqlservercsapocmigration ` 174 | -TargetDbName AdventureWorks ` 175 | -Expand MigrationStatusDetails 176 | 177 | $monitoringMigration.ProvisioningState | Format-List 178 | 179 | ``` 180 | 181 | 3. MigrationStatus should be **InProgress, Canceling, Failed, or Succeeded** 182 | 183 | ```powershell 184 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 185 | -ResourceGroupName ` 186 | -SqlDbInstanceName ` 187 | -TargetDbName AdventureWorks ` 188 | -Expand MigrationStatusDetails 189 | 190 | $monitoringMigration.MigrationStatus | Format-List 191 | ``` 192 | 193 | The following example brings complete details 194 | 195 | ```powershell 196 | 197 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 198 | -ResourceGroupName oneclickpoc ` 199 | -SqlDbInstanceName sqlservercsapocmigration ` 200 | -TargetDbName AdventureWorks ` 201 | -Expand MigrationStatusDetails 202 | 203 | $monitoringMigration.MigrationStatus | Format-List 204 | ``` 205 | 206 | You can also use the Azure Portal to monitor migration. 207 | 208 | ![migration succeeded](/media/sqldb-migration-succeeded.png) 209 | 210 | ### Performing cutover 211 | 212 | Use the **Invoke-AzDataMigrationCutoverToSqlManagedInstance** command to perform cutover. 213 | 214 | 1. Obtain the MigrationOperationId 215 | 216 | ```powershell 217 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance -ResourceGroupName "" -ManagedInstanceName "" -TargetDbName "AdventureWorks" 218 | ``` 219 | 220 | 2. Perform Cutover 221 | 222 | ```powershell 223 | Invoke-AzDataMigrationCutoverToSqlManagedInstance -ResourceGroupName "" -ManagedInstanceName "" -TargetDbName "AdventureWorks" -MigrationOperationId $monitoringMigration.MigrationOperationId 224 | ``` 225 | 226 | ## Migrating at scale 227 | 228 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/PowerShell/scripts/multiple%20databases) 229 | 230 | ## Page Navigator 231 | 232 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 233 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 234 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 235 | -------------------------------------------------------------------------------- /AzureSQLMI/migration/PowerShell/azuresqlmi-online-migration-using-file-share-ps.md: -------------------------------------------------------------------------------- 1 | # Online migration for Azure SQL Managed Instance using File Share using PowerShell 2 | 3 | Perform online migrations of your SQL Server databases running on-premises, SQL Server on Azure Virtual Machines, or any virtual machine running in the cloud (private, public) to Azure SQL Database using the Azure SQL Migration extension. 4 | 5 | ### Prerequisites 6 | 7 | - SQL Server with Windows authentication or SQL authentication access 8 | - .Net Core 3.1 (Already installed) 9 | - Az.DataMigration PowerShell module 10 | 11 | ## Getting Started 12 | 13 | > [!CAUTION] 14 | > 15 | > - **Connect to the Jump Box VM** 16 | > - VM name: **jb-migration** 17 | > - Use the credentials provided on the deploy page. 18 | 19 | Open a [Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us). It is already installed in the VM and by default it uses PowerShell. 20 | 21 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 22 | 23 | In addition, the Azure PowerShell command [Az.DataMigration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0) can be used to manage data migration at scale. 24 | 25 | 1. Run the following to log in from your client using your default web browser if you are not logged in. 26 | 27 | ```powershell 28 | Connect-AzAccount -Subscription 29 | ``` 30 | 31 | If you have more than one subscription, you can select a particular subscription. 32 | 33 | ```powershell 34 | Set-AzContext -SubscriptionId 35 | ``` 36 | 37 | The [Azure SQL migration extension for Azure Data Studio](https://learn.microsoft.com/en-us/sql/azure-data-studio/extensions/azure-sql-migration-extension?view=sql-server-ver16) enables you to assess, get Azure recommendations and migrate your SQL Server databases to Azure. 38 | 39 | In addition, the PowerShell command [Data Migration](https://learn.microsoft.com/en-us/powershell/module/az.datamigration/?view=azps-10.0.0#data-migrationt) can be used to manage data migration at scale. 40 | 41 | 2. Backup database 42 | 43 | ```sql 44 | USE master 45 | BACKUP DATABASE AdventureWorks2019 TO Disk = 'C:\temp\backup\AdventureWorks2019.bak' 46 | WITH CHECKSUM 47 | ``` 48 | 49 | ### Register Database Migration Service with self-hosted Integration Runtime 50 | 51 | 1. Use the **Get-AzDataMigrationSqlServiceAuthKey** command to obtain AuthKeys. 52 | 53 | ```powershell 54 | $AuthKeys = Get-AzDataMigrationSqlServiceAuthKey ` 55 | -ResourceGroupName "" ` 56 | -SqlMigrationServiceName "PoCMigrationService" 57 | ``` 58 | 59 | - The following example obtains the authKey: 60 | 61 | ```powershell 62 | $AuthKeys = Get-AzDataMigrationSqlServiceAuthKey ` 63 | -ResourceGroupName "oneclickpoc" ` 64 | -SqlMigrationServiceName "PoCMigrationService" 65 | ``` 66 | 67 | 2. Change the PowerShell execution policy. 68 | 69 | ```powershell 70 | Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned 71 | ``` 72 | 73 | 3. Use the **az datamigration register-integration-runtime** command to register the service on Integration Runtime. 74 | 75 | ```powershell 76 | Register-AzDataMigrationIntegrationRuntime ` 77 | -AuthKey ` 78 | ``` 79 | 80 | The following example registers the service on Integration Runtime: 81 | 82 | ```powershell 83 | Register-AzDataMigrationIntegrationRuntime ` 84 | -AuthKey $AuthKeys.AuthKey1 ` 85 | ``` 86 | 87 | > [!WARNING] 88 | > If you receive an error message saying: "RegisterIntegrationRuntime.ps1 cannot be loaded because running scripts is disabled on this system", please, run the following command and re-run the PowerShell command above. 89 | > 90 | > `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned` 91 | 92 | ### Start database migration 93 | 94 | > [!CAUTION] 95 | > 96 | > - **Connect to the Jump Box VM** 97 | > - VM name: **jb-migration** 98 | > - Use the credentials provided on the deploy page. 99 | 100 | 1. Convert the passwords to secure string 101 | 102 | ```powershell 103 | $sourcePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 104 | $sourceFileSharePassword = ConvertTo-SecureString "My`$upp3r`$ecret" -AsPlainText -Force 105 | 106 | ``` 107 | 108 | 2. Use the **New-AzDataMigrationToSqlManagedInstance** command to create and start a database migration. 109 | 110 | ```powershell 111 | New-AzDataMigrationToSqlManagedInstance ` 112 | -ResourceGroupName ` 113 | -ManagedInstanceName ` 114 | -TargetDbName "AdventureWorks" ` 115 | -Kind "SqlMI" ` 116 | -Scope "/subscriptions//resourceGroups//providers/Microsoft.Sql/managedInstances/" ` 117 | -MigrationService "/subscriptions//resourceGroups//providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 118 | -StorageAccountResourceId "/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" ` 119 | -StorageAccountKey "" ` 120 | -FileSharePath "\\10.1.0.4\SQLBackup" ` 121 | -FileShareUsername "10.1.0.4\sqladmin" ` 122 | -FileSharePassword $sourceFileSharePassword ` 123 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 124 | -SourceSqlConnectionDataSource "10.1.0.4" ` 125 | -SourceSqlConnectionUserName "sqladmin" ` 126 | -SourceSqlConnectionPassword $sourcePassword ` 127 | -SourceDatabaseName "AdventureWorks2019" ` 128 | ``` 129 | 130 | The following example creates and starts a migration of complete source database with target database name AdventureWorks: 131 | 132 | ```powershell 133 | New-AzDataMigrationToSqlManagedInstance ` 134 | -ResourceGroupName oneclickpoc ` 135 | -ManagedInstanceName sqlmicsapocmigration ` 136 | -TargetDbName "AdventureWorks" ` 137 | -Kind "SqlMI" ` 138 | -Scope "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Sql/managedInstances/sqlmicsapocmigration" ` 139 | -MigrationService "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.DataMigration/SqlMigrationServices/PoCMigrationService" ` 140 | -StorageAccountResourceId "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/oneclickpoc/providers/Microsoft.Storage/storageAccounts/storagepocmigration" ` 141 | -StorageAccountKey "XXXXXXXX" ` 142 | -FileSharePath "\\10.1.0.4\SQLBackup" ` 143 | -FileShareUsername "10.1.0.4\sqladmin" ` 144 | -FileSharePassword $sourceFileSharePassword ` 145 | -SourceSqlConnectionAuthentication "SqlAuthentication" ` 146 | -SourceSqlConnectionDataSource "10.1.0.4" ` 147 | -SourceSqlConnectionUserName "sqladmin" ` 148 | -SourceSqlConnectionPassword $sourcePassword ` 149 | -SourceDatabaseName "AdventureWorks2019" ` 150 | ``` 151 | 152 | > [!TIP] 153 | > 154 | > You should take all necessary backups. 155 | 156 | Learn more about using [Powershell to migrate](https://github.com/Azure-Samples/data-migration-sql/blob/main/PowerShell/sql-server-to-sql-mi-blob.md#start-online-database-migration) 157 | 158 | ### Monitoring migration 159 | 160 | Use the **Get-AzDataMigrationToSqlManagedInstance** command to monitor migration. 161 | 162 | 1. Get complete migration details 163 | 164 | ```powershell 165 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 166 | -ResourceGroupName ` 167 | -SqlDbInstanceName ` 168 | -TargetDbName AdventureWorks ` 169 | -Expand MigrationStatusDetails 170 | 171 | $monitoringMigration 172 | ``` 173 | 174 | The following example brings complete details 175 | 176 | ```powershell 177 | 178 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 179 | -ResourceGroupName oneclickpoc ` 180 | -SqlDbInstanceName sqlservercsapocmigration ` 181 | -TargetDbName AdventureWorks ` 182 | -Expand MigrationStatusDetails 183 | 184 | $monitoringMigration 185 | 186 | ``` 187 | 188 | 2. ProvisioningState should be **Creating, Failed, or Succeeded** 189 | 190 | ```powershell 191 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 192 | -ResourceGroupName ` 193 | -SqlDbInstanceName ` 194 | -TargetDbName AdventureWorks ` 195 | -Expand MigrationStatusDetails 196 | 197 | $monitoringMigration.ProvisioningState | Format-List 198 | ``` 199 | 200 | The following example brings complete details 201 | 202 | ```powershell 203 | 204 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 205 | -ResourceGroupName oneclickpoc ` 206 | -SqlDbInstanceName sqlservercsapocmigration ` 207 | -TargetDbName AdventureWorks ` 208 | -Expand MigrationStatusDetails 209 | 210 | $monitoringMigration.ProvisioningState | Format-List 211 | 212 | ``` 213 | 214 | 3. MigrationStatus should be **InProgress, Canceling, Failed, or Succeeded** 215 | 216 | ```powershell 217 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 218 | -ResourceGroupName ` 219 | -SqlDbInstanceName ` 220 | -TargetDbName AdventureWorks ` 221 | -Expand MigrationStatusDetails 222 | 223 | $monitoringMigration.MigrationStatus | Format-List 224 | ``` 225 | 226 | The following example brings complete details 227 | 228 | ```powershell 229 | 230 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance ` 231 | -ResourceGroupName oneclickpoc ` 232 | -SqlDbInstanceName sqlservercsapocmigration ` 233 | -TargetDbName AdventureWorks ` 234 | -Expand MigrationStatusDetails 235 | 236 | $monitoringMigration.MigrationStatus | Format-List 237 | ``` 238 | 239 | You can also use the Azure Portal to monitor migration. 240 | 241 | ![migration succeeded](/media/sqldb-migration-succeeded.png) 242 | 243 | ### Performing cutover 244 | 245 | Use the **Invoke-AzDataMigrationCutoverToSqlManagedInstance** command to perform cutover. 246 | 247 | 1. Obtain the MigrationOperationId 248 | 249 | ```powershell 250 | $monitoringMigration = Get-AzDataMigrationToSqlManagedInstance -ResourceGroupName "" -ManagedInstanceName "" -TargetDbName "AdventureWorks" 251 | ``` 252 | 253 | 2. Perform Cutover 254 | 255 | ```powershell 256 | Invoke-AzDataMigrationCutoverToSqlManagedInstance -ResourceGroupName "" -ManagedInstanceName "" -TargetDbName "AdventureWorks" -MigrationOperationId $monitoringMigration.MigrationOperationId 257 | ``` 258 | 259 | ## Migrating at scale 260 | 261 | This script performs an [end to end migration of multiple databases in multiple servers](https://github.com/Azure-Samples/data-migration-sql/tree/main/PowerShell/scripts/multiple%20databases) 262 | 263 | ## Page Navigator 264 | 265 | - [SQL Server migration one-click PoC to Azure SQL](../../../README.md) 266 | - [One-click PoC to Azure SQL DB](../../../AzureSQLDB/deploy/README.md) 267 | - [One-click PoC to Azure SQL MI](../../../AzureSQLMI/deploy/README.md) 268 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQL Server migration one-click PoC to Azure SQL 2 | 3 | This one-click deployment allows you to deploy a Proof-of-Concept environment of Azure SQL VM migration to Azure SQL with encapsulated best practices and step-by-step execution steps that will enable you to test, adjust and fully deploy the automated solution at scale. 4 | This approach can help with large-scale migrations for specific workload use cases. 5 | 6 | ## One-click PoC 7 | 8 | Take advantage of this one-click SQL Migration PoC to accelerate your migration to Azure SQL. 9 | 10 | |Deployment Options | One-Click PoC | 11 | |--------- | --------- | 12 | | SQL Server to Azure SQL Managed Instance | [![One-click PoC to Azure SQL MI](./media/Azure-DevOps.svg)](./AzureSQLMI/deploy/README.md) [One-click PoC to Azure SQL MI](./AzureSQLMI/deploy/README.md) | 13 | | SQL Server to Azure SQL Database | [![One-click PoC to Azure SQL DB](./media/Azure-DevOps.svg)](./AzureSQLDB/deploy/README.md) [One-click PoC to Azure SQL DB](./AzureSQLDB/deploy/README.md) | 14 | 15 | ## Migration Scenarios 16 | 17 | | Destination | Migration Scenario | Scripting language | User experience (UX) | 18 | |--------- |--------- |:---------: |:---------: | 19 | | Azure SQL DB | Assessment and SKU recommendation | [CLI](./AzureSQLDB/assessment/CLI/azuresqldb-assessment-sku-using-cli.md) / [PowerShell](./AzureSQLDB/assessment/PowerShell/azuresqldb-assessment-sku-using-ps.md) | [ADS](./AzureSQLDB/assessment/ADS/azuresqldb-assessment-sku-using-ads.md)| 20 | | Azure SQL DB | Offline migration for Azure SQL Database | [CLI](./AzureSQLDB/migration/CLI/azuresqldb-offline-migration-using-cli.md) / [PowerShell](/AzureSQLDB/migration/PowerShell/azuresqldb-offline-migration-using-ps.md)| | 21 | |Azure SQL MI | Assessment and SKU recommendation | [CLI](./AzureSQLMI/assessment/CLI/azuresqlmi-assessment-sku-using-cli.md) / [PowerShell](./AzureSQLMI/assessment/PowerShell/azuresqlmi-assessment-sku-using-ps.md) | [ADS](./AzureSQLMI/assessment/ADS/azuresqlmi-assessment-sku-using-ads.md)| 22 | |Azure SQL MI | Offline migration for Azure SQL Managed Instance using Storage Account | [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) / [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-azure-storage-ps.md)| | 23 | |Azure SQL MI | Offline migration for Azure SQL Managed Instance using File Share | [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) / [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) | | 24 | |Azure SQL MI | Online migration for Azure SQL Managed Instance using Storage Account | [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) / [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-online-migration-using-azure-storage-ps.md)| | 25 | |Azure SQL MI | Online migration for Azure SQL Managed Instance using File Share | [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) / [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 26 | |Azure SQL MI | Login migration | [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-login-migration-using-cli.md) / [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-login-migration-using-ps.md) | | 27 | 28 | ## Youtube walkthrough 29 | 30 | This short video will help you to get familiarized with the SQL Server migration one-click PoC to Azure SQL. 31 | 32 | [![Youtube SQL Server migration one-click PoC to Azure SQL](https://img.youtube.com/vi/qHaGY1oP7WU/0.jpg)](https://www.youtube.com/watch?v=qHaGY1oP7WU) 33 | 34 | ## Prerequisites 35 | 36 | - You need to have at least an owner role or contributor role for the Azure subscription. A separate resource group should be created and delegated roles necessary for this proof of concept. 37 | - Check this documentation for [RBAC role-assignments](https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-steps). 38 | - Make sure that the Microsoft.DataMigration [resource provider is registered in your subscription.](https://learn.microsoft.com/en-us/azure/dms/quickstart-create-data-migration-service-portal#register-the-resource-provider) 39 | 40 | ## Contributing 41 | 42 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 43 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 44 | the rights to use your contribution. For details, visit . 45 | 46 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide 47 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions 48 | provided by the bot. You will only need to do this once across all repos using our CLA. 49 | 50 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 51 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 52 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 53 | 54 | ## Trademarks 55 | 56 | This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft 57 | trademarks or logos is subject to and must follow 58 | [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). 59 | Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. 60 | Any use of third-party trademarks or logos are subject to those third-party's policies. 61 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # TODO: The maintainer of this repo has not yet edited this file 2 | 3 | **REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? 4 | 5 | - **No CSS support:** Fill out this template with information about how to file issues and get help. 6 | - **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. 7 | - **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. 8 | 9 | *Then remove this first heading from this SUPPORT.MD file before publishing your repo.* 10 | 11 | # Support 12 | 13 | ## How to file issues and get help 14 | 15 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 16 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 17 | feature request as a new Issue. 18 | 19 | For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE 20 | FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER 21 | CHANNEL. WHERE WILL YOU HELP PEOPLE?**. 22 | 23 | ## Microsoft Support Policy 24 | 25 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 26 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # SQL Server migration one-click PoC to Azure SQL 2 | 3 | ## Table of Contents 4 | 5 | 1. [SQL Server migration one-click PoC to Azure SQL](README.md) 6 | 2. [One-click PoC to Azure SQL DB](./AzureSQLDB/deploy/README.md) 7 | - ***Assessment and SKU recommendation*** 8 | - [CLI](./AzureSQLDB/assessment/CLI/azuresqldb-assessment-sku-using-cli.md) 9 | - [PowerShell](./AzureSQLDB/assessment/PowerShell/azuresqldb-assessment-sku-using-ps.md) 10 | - ***Offline migration*** 11 | - [CLI](./AzureSQLDB/migration/CLI/azuresqldb-offline-migration-using-cli.md) 12 | - [PowerShell](/AzureSQLDB/migration/PowerShell/azuresqldb-offline-migration-using-ps.md) 13 | 14 | 3. [One-click PoC to Azure SQL MI](./AzureSQLDB/deploy/README.md) 15 | - ***Assessment and SKU recommendation*** 16 | - [CLI](./AzureSQLMI/assessment/CLI/azuresqlmi-assessment-sku-using-cli.md) 17 | - [PowerShell](./AzureSQLMI/assessment/PowerShell/azuresqlmi-assessment-sku-using-ps.md) 18 | - ***Offline migration using Storage Account*** 19 | - [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) 20 | - [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-azure-storage-ps.md) 21 | - ***Offline migration using File Share*** 22 | - [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) 23 | - [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 24 | - ***Online migration using Storage Account*** 25 | - [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-azure-storage-cli.md) 26 | - [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-online-migration-using-azure-storage-ps.md) 27 | - ***Online migration using File Share*** 28 | - [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-offline-migration-using-file-share-cli.md) 29 | - [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-offline-migration-using-file-share-ps.md) 30 | - ***Login migration*** 31 | - [CLI](./AzureSQLMI/migration/CLI/azuresqlmi-login-migration-using-cli.md) 32 | - [PowerShell](/AzureSQLMI/migration/PowerShell/azuresqlmi-login-migration-using-ps.md) 33 | -------------------------------------------------------------------------------- /media/ADS/ads-assessment-install-extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-assessment-install-extension.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-connect-sql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-connect-sql.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-migration-extension-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-migration-extension-home.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-select-databases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-select-databases.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-sku-recommendation-view-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-sku-recommendation-view-details.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-sku-recommendation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-sku-recommendation.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-summary.png -------------------------------------------------------------------------------- /media/ADS/ads-sqldb-assessment-target-platform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqldb-assessment-target-platform.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-connect-sql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-connect-sql.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-migration-extension-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-migration-extension-home.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-select-databases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-select-databases.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-sku-recommendation-view-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-sku-recommendation-view-details.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-sku-recommendation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-sku-recommendation.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-summary.png -------------------------------------------------------------------------------- /media/ADS/ads-sqlmi-assessment-target-platform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/ADS/ads-sqlmi-assessment-target-platform.png -------------------------------------------------------------------------------- /media/ARM-Deployment.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /media/Azure-DevOps.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /media/Bicep-Logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /media/Terraform-Logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /media/sqldb-migration-succeeded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqldb-migration-succeeded.png -------------------------------------------------------------------------------- /media/sqldb-resource-visualizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqldb-resource-visualizer.png -------------------------------------------------------------------------------- /media/sqldb-sku-recommendation-cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqldb-sku-recommendation-cli.png -------------------------------------------------------------------------------- /media/sqldb-sku-recommendation-html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqldb-sku-recommendation-html.png -------------------------------------------------------------------------------- /media/sqldb-sku-recommendation-ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqldb-sku-recommendation-ps.png -------------------------------------------------------------------------------- /media/sqlmi-connectionstring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqlmi-connectionstring.png -------------------------------------------------------------------------------- /media/sqlmi-login-migration-cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqlmi-login-migration-cli.png -------------------------------------------------------------------------------- /media/sqlmi-resource-visualizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqlmi-resource-visualizer.png -------------------------------------------------------------------------------- /media/sqlmi-sku-recommendation-cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqlmi-sku-recommendation-cli.png -------------------------------------------------------------------------------- /media/sqlmi-sku-recommendation-html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqlmi-sku-recommendation-html.png -------------------------------------------------------------------------------- /media/sqlmi-sku-recommendation-ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/SQL-Migration-AzureSQL-PoC/408bfa6c802f5229677ac8fba2eff748aaffd8b2/media/sqlmi-sku-recommendation-ps.png -------------------------------------------------------------------------------- /script/JumpBoxPostInstallation.ps1: -------------------------------------------------------------------------------- 1 | Start-Transcript -Path C:\psLogs.txt -Append 2 | 3 | # Install Chocolatey 4 | try { 5 | Set-ExecutionPolicy Unrestricted -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) 6 | } 7 | catch { 8 | Write-Host "Error to install chocolatey and set execution policy" 9 | } 10 | 11 | try { 12 | # Install dotnet 13 | Write-Host "Installing DotNet Core" 14 | choco install dotnetcore -y 15 | Write-Host "dotnetcore was installed successfully" 16 | Write-Host "Installing Dotnet 6" 17 | choco install dotnet-6.0-sdk -y 18 | Write-Host "dotnet-6.0-sdk was installed successfully" 19 | Write-Host "Installing Dotnet 7 runtime" 20 | choco install dotnet-runtime -y 21 | Write-Host "dotnet-runtime was installed successfully" 22 | 23 | Write-Host "Setting variable" 24 | $env:Path += "C:\Program Files\dotnet;" 25 | [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine) 26 | refreshenv 27 | } 28 | catch { 29 | Write-Host "Error to installing dotnet" 30 | } 31 | 32 | try { 33 | # Install Software 34 | Write-Host "Installing Azure Data Studio" 35 | choco install azure-data-studio -y 36 | Write-Host "Azure Data Studio was installed successfully" 37 | Write-Host "Installing Azure CLI" 38 | choco install azure-cli -y 39 | Write-Host "Azure CLI was installed successfully" 40 | 41 | #$env:Path += "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;" 42 | $env:Path += "C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;" 43 | [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine) 44 | refreshenv 45 | } 46 | catch { 47 | Write-Host "Error to install Azure Data Studio or Azure CLI" 48 | Write-Host "Error to set variables: 'C:\Program Files\dotnet;' and 'C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;'" 49 | } 50 | 51 | try { 52 | # Installing Windows Terminal 53 | Write-Host "Installing Windows Terminal" 54 | choco install microsoft-windows-terminal -y 55 | } 56 | catch { 57 | Write-Host "Error to install Windows Terminal" 58 | } 59 | 60 | try { 61 | Write-Host "Installing PowerShell module" 62 | Install-PackageProvider -Name NuGet -Force -Confirm:$false 63 | Install-Module -Name Az.DataMigration -Force -Confirm:$false 64 | Write-Host "Az.DataMigration was installed successfully" 65 | 66 | } 67 | catch { 68 | Write-Host "Error to install PowerShell module" 69 | } 70 | 71 | # Function to create folders 72 | function CreateFolder { 73 | param ( 74 | [Parameter()] [String] $FolderName 75 | ) 76 | 77 | if (Test-Path $FolderName) { 78 | 79 | Write-Host "Folder Exists" 80 | } 81 | else { 82 | 83 | #PowerShell Create directory if not exists 84 | New-Item $FolderName -ItemType Directory 85 | Write-Host "Folder was created successfully" 86 | } 87 | 88 | } 89 | 90 | Write-Host "Creating folders" 91 | #Destination Path 92 | $OutputTargetDirectory = "C:\temp\output" 93 | $ProjectsTargetDirectory = "C:\temp\projects" 94 | $SHIRTargetDirectory = "C:\temp\SHIR" 95 | 96 | #Create Folders 97 | 98 | CreateFolder $OutputTargetDirectory 99 | CreateFolder $ProjectsTargetDirectory 100 | CreateFolder $SHIRTargetDirectory 101 | Write-Host "Folders were created successfully" 102 | 103 | # Adding some Nuget sources 104 | Write-Host "Adding Nuget source" 105 | try { 106 | dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org 107 | Write-Host "Nuget source added correctly" 108 | } 109 | catch { 110 | Write-Host "Error adding Nuget source" 111 | } 112 | 113 | # Installing SqlPackage - This is not working! 114 | Write-Host "Installing SqlPackage" 115 | try { 116 | Set-Location "C:\Program Files\dotnet" 117 | dotnet tool install -g microsoft.sqlpackage 118 | $env:Path += "C:\Windows\System32\config\systemprofile\.dotnet\tools;" 119 | [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine) 120 | refreshenv 121 | Write-Host "SqlPackage throught dotnet was installed successfully" 122 | } 123 | catch { 124 | Write-Host "Error to install SqlPackage" 125 | Write-Host "Error to set variables: 'C:\Windows\System32\config\systemprofile\.dotnet\tools;'" 126 | } 127 | 128 | Write-Host "Installing SqlPackage through msi" 129 | $wc = New-Object net.webclient 130 | 131 | try { 132 | Write-Host "Downloading DacFx Framework" 133 | $dacfx_url = "https://aka.ms/dacfx-msi" 134 | $local_dacfx_file = "C:\temp\DacFramework.msi" 135 | $wc.Downloadfile($dacfx_url, $local_dacfx_file) 136 | 137 | #Invoke-WebRequest -Uri https://aka.ms/dacfx-msi -OutFile C:\temp\DacFramework.msi; 138 | Write-Host "Installing DacFx Framework" 139 | Start-Process msiexec.exe -Wait -ArgumentList '/I C:\temp\DacFramework.msi /quiet'; 140 | $env:Path += "C:\Program Files\Microsoft SQL Server\160\DAC\bin;" 141 | [Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine) 142 | refreshenv 143 | Write-Host "SqlPackage throught msi was installed successfully" 144 | 145 | } 146 | catch { 147 | Write-Host "Error to install SqlPackage" 148 | } 149 | 150 | try { 151 | # Downaloading and installig Integration Runtime 152 | Write-Host "Downloading Integration Runtime" 153 | $dacfx_url = "https://download.microsoft.com/download/E/4/7/E4771905-1079-445B-8BF9-8A1A075D8A10/IntegrationRuntime_5.38.8794.1.msi" 154 | $local_dacfx_file = "C:\temp\SHIR\IntegrationRuntime_5.38.8794.1.msi" 155 | $wc.Downloadfile($dacfx_url, $local_dacfx_file) 156 | 157 | 158 | 159 | # Invoke-WebRequest -Uri https://download.microsoft.com/download/E/4/7/E4771905-1079-445B-8BF9-8A1A075D8A10/IntegrationRuntime_5.36.8726.3.msi -OutFile C:\temp\SHIR\IntegrationRuntime_5.36.8726.3.msi; 160 | Write-Host "Installing Integration Runtime" 161 | Start-Process msiexec.exe -Wait -ArgumentList '/I C:\temp\SHIR\IntegrationRuntime_5.38.8794.1.msi /quiet'; 162 | } 163 | catch { 164 | Write-Host "Error to install Integration Runtime" 165 | } 166 | 167 | try { 168 | # add extension 169 | Write-Host "Adding AZ extension" 170 | az extension add --name datamigration --system 171 | } 172 | catch { 173 | Write-Host "Error to add datamigration AZ extension " 174 | } 175 | 176 | try { 177 | # Installing Azure SQL migration extension for Azure Data Studio 178 | Write-Host "Installing Azure SQL migration extension" 179 | Start-Process -filePath "C:\Program Files\Azure Data Studio\bin\azuredatastudio" -ArgumentList "--install-extension Microsoft.sql-migration","--force" 180 | } 181 | catch { 182 | Write-Host "Error to install Azure SQL migration extension" 183 | } 184 | 185 | Stop-Transcript 186 | 187 | 188 | --------------------------------------------------------------------------------