Archive

Archive for the ‘Azure SQL Managed Instance’ Category

Azure SQL Managed Instance – Migrate a Database Using Backup and Restore

November 15, 2018 2 comments

If you have run through my last Managed Instance blog post, you have a Managed Instance at your disposal.  The PowerShell script for creating the network requirements also contains steps to create an Azure VM in a different subnet in the same VNet.  Unless you have a site-to-site VPN or Express Route between your on-prem environment and Azure, you will use this VM to connect to your Managed Instance.

Install Management Studio on the Azure VM.  To connect to your Managed Instance, you will need the host name for your Managed Instance.  You can find the Managed Instance host name on the resource page for your Managed Instance in the Portal.

GetMiHostName

Open Management Studio and copy the instance name into the Server field in Management Studio and enter the admin account and password you specified on creation.  Click connect.

ConnectToMi

Once the Managed Instance opens, you will be able to navigate it using Object Explorer.  The experience will look very familiar if you are used to using SSMS.  You will see all four system databases and SQL Server Agent.  If you expand the Agent entry in Object Explorer, you will notice that Alerts do not currently exist.  Also, note that the SQL version number is listed as 12.0.2000.8.  This is NOT SQL Server 2014.  Azure SQL Database and Azure SQL Managed Instance are currently at version 12.

ObjectExplorer

To create your first database, you will need to upload a backup file to Azure blob storage. If you do not have a Storage Account, click the Add button at the top of your Resource Group.

AddStorageAccount.png

In the search box, enter Storage Account.   Select Storage account – blob, file, table, queue.  On the next screen, click Create.

EnterStorageAccount.png

Confirm your subscription and resource group are correct. Select and name your storage account.  Select the same location as your Managed Instance, Standard performance, and Storage V2 (general purpose V2).  For this example, I selected Locally-redundant storage (LRS) because it is the least expensive option. Click the Review and Create button.

NameStorageAccount.png

Once the storage account is provisioned, you will need to create a container to hold the backup file.  I think of the storage account as a drive and containers as folders on that drive.  Under Services, click Blobs.

ClickBlobs.png

Once the Blob service screen opens, click Containers at the top of the screen.  Name your container and leave the Public access level set to the default.  Click OK.

ClickContainer

NameContainer.png

 

After your container is created, click the container name to open it.  Click the Upload button at the top of the screen.

UploadFile.png

Click the folder button to the right of the Files text box and select your backup file.  Once the Upload button becomes active, click it.  Once the upload is complete, you are ready to restore a database to your Managed Instance.

SelectFile

Go back to your VM and connect to your Managed Instance.  Right-click on Databases in Object Explorer and select Restore Database.

REstoreDatabase.png

Click the Device radio button.  Click the ellipsis button to the right of the Device text box.  Notice that URL is the only entry available in the Backup media type dropdown.  This is because you must restore a Managed Database from Azure blob storage.

SelectBackup.png

 

Click the Add button.  You will be prompted to sign into your Azure subscription.  Click the Sign In button.SignIn.png

Enter the login and password for your Azure account.  On the next dialogue, select your subscription, storage account, and container.  Click the Create Credential button to create a Shared Access Signature to allow SQL Server to access Azure storage.

SelectContainer.png

Once the credential populates in the Shared Access Signature Generated text box, click OK.

SelectCredential.png

You will return to the Select a Backup File Location dialog with the Azure storage container and Shared Access Signature boxes populated.  Click OK

OkBackupLocation.png

If you have used Management Studio to select a backup file to restore, the Locate Backup File in Microsoft Azure will look familiar.  Expand Containers in the left-hand pane and select your container.  You should see your backup file in the right-hand pane.  Click the file name and click OK.

SelectBackupFile.png

The Select backup devices dialog will display with your backup file selected.  Click OK.

BackupSelected.png

The Restore Database dialog will display with your backup file listed in the Backup sets to restore text box.  Note that there are no pages in the Select a page pane for Files or Options.  Because storage is managed for a Managed Instance, you cannot select where the files will be placed and you cannot set a database to NORECOVERY.  Click the Script button.

DatabaseRestore.png

A query window will open in Management Studio containing the RESTORE script that SQL Server will execute if you click the OK button on the Restore Database dialog.  Navigate to that script.  The RESTORE statement is extremely simple:

RestoreStatement.png

You cannot add any WITH clauses to the statement.  If you try you will receive the following error:

ErrorMessage

To complete the restore of your database, execute the restore script.  Once the restore completes, you will be able to access it using Management Studio. In my next post, I will provide additional options for migrating databases and instance-level objects to Managed Instance.

 

 

 

 

Azure SQL Managed Instance – Provisioning

October 31, 2018 3 comments

Once you have created the prerequisites, you are ready to create your first Managed Instance.  As of now, Managed Instance is only available in the following subscription types:

  • Pay-As-You-Go
  • Enterprise Agreement
  • Cloud Service Provider

Information about subscription and resource limitations can be found here.  I will update this with any changes.

For a PowerShell script to provision a Managed Instance, see the end of the post.

Add Resource

To provision a Managed Instance in the Azure Resource Manager portal, connect to your subscription and open the resource group in which you created the prerequisites.  Click the Add button at the top of the page:

A1 - AddMi

Search Resources

On the Everything page, search for Azure SQL Managed Instance and click the name in Results.

A2 - SearchMi

The portal will display an overview of the Managed Instance resource and links to Managed Instance documentation, pricing, and information about the Database Migration Service.  Confirm that you want to create a new Managed Instance and click Create.

Select Managed Instance

A3 - MiDisclaimer

Enter Managed Instance Information

In the SQL Managed Instance pane, select the subscription in which you created the prerequisite resources.  Enter a name for the Managed Instance, an admin account name, and an admin password.

NOTE: The admin password must be at least 16 characters in length.

Select the resource group and location in which the prerequisite resource exist.  If the virtual network and subnet were created successfully, the subnet that contains the route table will appear in the Virtual Network dropdown.  Select it and the pricing tier link will unlock.

A4 - MiInformation.png  

Choose Pricing Tier

I will provide more information about pricing tiers and processor generations in a subsequent post.  For this example, I will select a General Purpose Managed Instance containing 8 vCores and 32GB of storage.  Select the desired parameters and click Apply.

A5 - ConfigureMiPerformance

Create Managed Instance

At this point you are ready to create your first Managed Instance.  Note that the initial creation of a Managed Instance in a subnet can take up to 6 hours.  Click the Create button to start the process.

A6 - CreateMi

View Managed Instance

Navigate back to your resource group.  Once the Managed Instance is created, click the Managed Instance name on the Overview page.

A7 - SelectMi

Celebrate!

The Overview for the Managed Instance will display with a message that your Managed Instance is ready.  Congratulations!

A8 - MiOverview

In my next post, I will cover the process for connection to the Managed Instance and restoring a database.

<# NOTE: The initial deployment of an Availability Group to a subnet will take ~3 hours. <span 				data-mce-type="bookmark" 				id="mce_SELREST_start" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			>&#65279;</span>Subsequent deployment will take minutes #>
<# Connect to Azure Account #>
Connect-AzureRmAccount;

<# Initialize local variables     Confirm that resource group, location, VNet, and subnet are the same    as those for the Managed Instance prerequisites #>
$resourcegroup = "yourmirg";
$location = "eastus";
$miname = "yourmi";
$vnetname = "yourmivn";
$subnetname = "default";
$subscrname = "Your Subscription"

<# Get subscription ID for the specified subscription #>
$subscrid = (Get-AzureRmSubscription -SubscriptionName $subscrname).SubscriptionId;

<# Switch to the desired subscription #>
Set-AzureRmContext -SubscriptionID $subscrid;

<# Create a new Managed Instance    This example will create a General Purpose Managed Instance    with 8 Gen4 vCores, indicated by the GP_Gen4 sku    To create a Business Critical instance with Gen5 cores    use sku BC_Gen5 #>
New-AzureRmSqlManagedInstance -Name $miname `
-ResourceGroupName $resourcegroup `
-Location $location `
-AdministratorCredential (Get-Credential) `
-SubnetId "/subscriptions/$subscrid/resourceGroups/$resourcegroup/providers/Microsoft.Network/virtualNetworks/$vnetname/subnets/$subnetname" `
-LicenseType LicenseIncluded `
-StorageSizeInGB 32 `
-VCore 8 `
-SkuName GP_Gen4

Azure SQL Managed Instance – An Introduction

October 17, 2018 1 comment

IMPORTANT: According to this post from Microsoft, Managed Instance creation is currently supported for Enterprise Agreement, Pay-As-You-Go, and Cloud Service Provider subscriptions.  I will update this post when additional subscription types are added.

Historically there have been two offerings available for running SQL Server in Azure.  The first is Azure SQL Database, released in 2010, which is Platform as a Service (PaaS). The second is SQL Server on an Azure VM, which is Infrastructure as a Service (IaaS), also released in 2010.  The benefits and drawbacks of each offering is listed below.

 BenefitsDrawbacksUse Cases
Azure SQL DatabaseInfrastructure is fully managedLimited to a single databaseNew development in Azure
Cross-database communication is difficultMulti-tenant applications
No SQL Server Agent
Cannot be powered down
SQL Server on an Azure VMFull feature set of SQL Server
Client is responsible for managing infrastructureMigration of existing applications
Can be powered down to reduce costCreation of test environments
Multiple Databases
Cross-database communication
SQL Server Agent

The drawbacks of Azure SQL Database make it difficult to migrate existing applications, because of the number of application changes required.  Azure SQL Database is designed to be used for new development in Azure and for multi-tenant environments, where each tenant requires their own copy of a database.

The benefits of SQL Server on an Azure VM make it much easier to migrate an existing application to Azure.  However, the VMs underlying the application still have to be managed by the client.  This fails to take advantage of the management of resources in Azure, and uses Azure as a VM host.

A third option, Azure SQL Managed Instance, was released at the beginning of October 2018.  Managed Instance combines the best of the previous options.  With Managed Instance, the infrastructure is fully managed and the majority of the SQL Server feature set is available.  The full list of differences between a traditional install of SQL Server and Managed Instance can be found here.  A number of the most dramatic differences are listed below.

  • Filestream is not supported
  • Backups must be run to Azure Blob Storage
  • No control over file placement

In the following series of blog posts, I will detail the steps required for the following tasks:

Additionally, I will delve into the internals of an Azure SQL Managed Instance and describe where they differ from a regular SQL Server instance.

I am really excited about the options Azure SQL Managed Instance provides for migrating existing SQL applications to Azure and am looking forward to blogging about it.