Register Azure subscription to enable managed resources move

Login to selected subscription using PowerShell.

run following command to register:

Register-AzureRmProviderFeature -FeatureName ManagedResourcesMove -ProviderNamespace Microsoft.Compute

to get register status:

Get-AzureRmProviderFeature -FeatureName ManagedResourcesMove -ProviderNamespace Microsoft.Compute

would take a while, afterwards register MS Compute resource provider:

Register-AzureRmResourceProvider -ProviderNamespace Microsoft.Compute

 

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-move-resources#virtual-machines-limitations

 

Azure SQL Backup, restore and generate Scripts

Create copy of Db on same server (SQL STATEMENT):

CREATE DATABASE [gs-app-db-cpy] AS COPY OF [gs-app-db]

SSMS Backup options for on-prem server dbs:

Backup database [md-migration-himavaan] to disk =N’c:\gBaks\him.bak’

bak : Applicable for On-premise databases backups (From SSMS or SQLOPS tool : To create a bac file we Right Click Database >> Tasks >> Backup)

Backup and restore using BacPac file:

Create bacpac file : Applicable for Backups/Export Data Tier of Databases to/within Azure SQL Databases (From SSMS or SQLOPS tool : To create a bac file we Right Click Database >> Tasks >> Export Data Tier). BacPac is not consistent if data is cont. been written while BacPac is in progress so better is to create a copy of db and then create BacPac.

IMPORT BacPac file using Azure Portal:

Upload BacPac to some storage account and use import database feature on Azure portal. Note: provide correct admin username and password for that db otherwise import will fail.

import bacpac

 

POWERSHELL COPY DB  SERVER TO SERVER:

New-AzureRmSqlDatabaseCopy -ResourceGroupName “myResourceGroup” ` -ServerName $sourceserver ` -DatabaseName “MySampleDatabase” ` -CopyResourceGroupName “myResourceGroup” ` -CopyServerName $targetserver ` -CopyDatabaseName “CopyOfMySampleDatabase”

https://docs.microsoft.com/en-us/azure/sql-database/scripts/sql-database-copy-database-to-new-server-powershell

Generate DB Scripts:

This can be used to generate schema or schema and data scripts for db.
sql generate script.png