iaas, sql, rest and powershell

27
IaaS, SQL, REST and Powershell Why is IaaS useful and what can do with it

Upload: azurecoder

Post on 02-Dec-2014

353 views

Category:

Technology


2 download

DESCRIPTION

Building Sql Server in a Windows Azure Virtual Machine

TRANSCRIPT

Page 1: Iaas, sql, rest and powershell

IaaS, SQL, REST and Powershell

Why is IaaS useful and what can do with it

Page 2: Iaas, sql, rest and powershell

Introduction

AgendaIntroduction to IaaSSimple IaaS patterns for the EnterpriseSQL Server and IaaSDeploying via PowershellDeploying using RESTScripting updates to your VMSQL and High Availability in the Cloud

WhoRichard Conway (and Andy Cross), co-founders UK Windows Azure User Group and need to use this cache in their own application and will explain why!

Page 3: Iaas, sql, rest and powershell

What is IaaS?

Page 4: Iaas, sql, rest and powershell

IaaS is…

• By Definition and Function• Infrastructure as a Service• Permanent VM Roles (with a lot less hassle!)• A way of extending your windows network into the cloud securely• A way of migrating your existing application and processes into the cloud• A way of doing what you do on premise without large capital investment and

scaling to meet your needs quickly

• What can you do• Build a web farm• Build a Windows network• Build a virtual datacentre• Build a set of virtualised desktops to offload complex tasks (e.g. rendering)• Basically, building applications and entire organisations in the cloud!

Page 5: Iaas, sql, rest and powershell

Images Available at Preview

Windows Server 2008 R2

Windows Server 2008 R2 with SQL Server 2012 Evaluation

Windows Server 2012 Release Candidate

OpenSUSE 12.1

CentOS 6.2

Ubuntu 12.04

SUSE Linux Enterprise Server SP2

Page 6: Iaas, sql, rest and powershell

Installing a SQL VM via Powershell

Types and info on caches

Page 7: Iaas, sql, rest and powershell

Recap of demo• Download and install WAPP CmdLets• Download a .publishsettings file• Use Import-AzurePublishSettingsFile CmdLet• Use Set-AzureSubscription or Select-AzureSubscription to set the

correct subscription• To see a list of gallery and saved images Get-AzureVMImage• You need to specify an image name, a cloud service name, a machine

name, a VM size, a Windows password and a location• Use New-AzureVMConfig to provide the config, Add-

AzureProvisioningConfig to add the Windows provisioning, Add-AzureDataDisk to add an additional disk, Add-AzureEndpoint to setup an Azure endpoint on 1433

• Use Get-AzureDisk | Select DiskName and Remove-AzureDisk –DiskName –DeleteVHD to remove

Page 8: Iaas, sql, rest and powershell

What to do after an install …

• Remote desktop on to the machine• Update the SQL Server to use Mixed Mode authentication• Create and login and user with a password• Add the user to the dbowner role• Open an incoming port on the firewall to allow access to port 1433• Open up SSMS• Enter the credentials to the DNS endpoint • Login and manipulate the database• Take all of the above and script into a powershell script!

Page 9: Iaas, sql, rest and powershell

What the powershell script looks like to build the VM$img = "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd"$machinename = "ELASTASQLVHD"$hostedservice = "elastavhd"$size = "Small"$password = "Password900"$medialink = "http://elastastorage2.blob.core.windows.net/vhds/elastasql.vhd"$disklabel = "datasql"$sqllink = "http://elastastorage2.blob.core.windows.net/vhds/elastadata.vhd"

New-AzureVMConfig -name $machinename -InstanceSize $size -ImageName $img -MediaLocation $medialink -Verbose | Add-AzureProvisioningConfig -Windows -Password $password -Verbose | Add-AzureDataDisk -CreateNew -DiskSizeInGB 50 -DiskLabel $disklabel -MediaLocation $sqllink -Verbose | Add-AzureEndpoint -Name SqlEndpoint -Protocol tcp -PublicPort 1433 -LocalPort 1433 | New-AzureVM -ServiceName $hostedservice -Location "North Europe" -Verbose

Page 10: Iaas, sql, rest and powershell

What the powershell script looks like to build the VM$img = "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd"$machinename = "ELASTASQLVHD"$hostedservice = "elastavhd"$size = "Small"$password = "Password900"$medialink = "http://elastastorage2.blob.core.windows.net/vhds/elastasql.vhd"$disklabel = "datasql"$sqllink = "http://elastastorage2.blob.core.windows.net/vhds/elastadata.vhd"

New-AzureVMConfig -name $machinename -InstanceSize $size -ImageName $img -MediaLocation $medialink -Verbose | Add-AzureProvisioningConfig -Windows -Password $password -Verbose | Add-AzureDataDisk -CreateNew -DiskSizeInGB 50 -DiskLabel $disklabel -MediaLocation $sqllink -Verbose | Add-AzureEndpoint -Name SqlEndpoint -Protocol tcp -PublicPort 1433 -LocalPort 1433 | New-AzureVM -ServiceName $hostedservice -Location "North Europe" -Verbose

Page 11: Iaas, sql, rest and powershell

Deploying a SQL VM in C#Using Fluent Management

Page 12: Iaas, sql, rest and powershell

Simple Fluent Syntax

var manager = new SubscriptionManager(TestConstants.InsidersSubscriptionId);manager.GetVirtualMachinesManager() .AddCertificateFromStore(TestConstants.ManagementThumbprintIaaS) .CreateVirtualMachineDeployment() .AddToExistingCloudServiceWithName(TestConstants.CloudServiceNameIaaS) .WithDeploymentType(VirtualMachineTemplates.SqlServer2012) .WithStorageAccountForVhds(TestConstants.StorageServiceNameIaaS) .WithVmOfSize(VmSize.Small) .Deploy();

Page 13: Iaas, sql, rest and powershell

What the REST request is composed of …

• Deployment• RoleList• Role

• ConfigurationSet• Windows

• Domain Join• Certificates

• Linux• SSH

• Network• Endpoints

• Endpoint• Loadbalancer

• Subnet• Availability Set• DataDisks• DataDisk

• OS Disk• Role Size• Virtual Network• DNS Servers

POST https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/

Requests are asynchronous so you need to poll for success with the “x-ms-request-id”

Page 14: Iaas, sql, rest and powershell

DEMOFluent Management

Page 15: Iaas, sql, rest and powershell

VHDsHow to roll your own

Page 16: Iaas, sql, rest and powershell

Cloud

BlogStorage

Bring Your Own Server/VHDOn-Premises

On Premises Virtual Server

Provision VM from Image or Disk using portal, script or API

Use CaseForklift Migration of VMs

Sys Prepped Images

VHD Must Be Fixed Disk * CSUpload Can Convert on Upload

MyApp.vhd

Page 17: Iaas, sql, rest and powershell

Patterns with IaaSMigrating applications and using AD in the cloud

Page 18: Iaas, sql, rest and powershell

Migrating a Multi-VM Application

Cloud ServiceName: myapp1.cloudapp.net

Virtual MachineVM Name: appsrv110.1.5.6

Virtual MachineVM Name: appsrv210.1.5.7

DIP

Cloud Service Acts as a Networking BoundaryAll VMs in the same service can communicate directlyName resolution between VMs is automatic with Windows Azure provided DNS

Virtual MachineVM Name: SQLServer110.1.5.8

DIP DIP

Load BalancerPublic IP

Page 19: Iaas, sql, rest and powershell

Migrating an Intranet Application

Cloud Service

Mirrored DBs

HTTP

VPN GatewayHTTP

On Premises

AD / DNS

Exchange

Site to Site VPN Tunnel

Web/App

Web/App

Hardware Load Balancer on client side for load balancing across internal only VPN tunnel.

Load Balancer

Page 20: Iaas, sql, rest and powershell

Migrating an Intranet Application

Cloud Service

Mirrored DBs

HTTP

SLBVPN Gateway HTTP

On Premises

AD / DNS

Exchange

Site to Site VPN Tunnel

Web/App

Web/App

Software Load Balancer for Internal LBUse an SLB such as the ARR extension of IIS7.5 when site-to-site only connectivity is a requirement.

Page 21: Iaas, sql, rest and powershell

Domain Controller On-Premises

The Virtual Networkin Windows Azure

Gateway

SQL ServersIIS Servers

Load BalancerPublic IP

Site to Site VPN Tunnel

AD Authentication+

On-Premises Resources

Contoso.com Active Directory

Contoso Corp Network

IIS Servers

AD / DNS

SQL Servers

Exchange

S2S VPN Device

Contoso.com Active Directory

Page 22: Iaas, sql, rest and powershell

Domain Controller in the Cloud

The Virtual Networkin Windows Azure

Gateway

SQL ServersIIS Servers

Load BalancerPublic IP

AD Replication+

On Premises Resources

AD / DNS

AD Auth

Site to Site VPN Tunnel

Contoso.com Active Directory

Contoso Corp Network

IIS Servers

AD / DNS

SQL Servers

Exchange

S2S VPN Device

Contoso.com Active Directory

Page 23: Iaas, sql, rest and powershell

Active Directory Cloud Only

The Virtual Networkin Windows Azure

Gateway

SQL ServersIIS Servers

Load BalancerPublic IP

On Premises ResourcesAD / DNS

AD Auth

Site to Site VPN Tunnel

Contoso Corp Network

IIS Servers

AD / DNS

SQL Servers

Exchange

S2S VPN Device

Contoso.com Active Directory

Extranet Active Directory

Page 24: Iaas, sql, rest and powershell

Best Practice GuidelinesSQL Dos and Donts

Page 25: Iaas, sql, rest and powershell

SQL Performance Best Practice

• From the SQL Server team!• Test performance with SQLIO (test the underlying storage

subsystem)• Use Storage Analytics as a free download to see the underlying

storage transactions• Don’t set max memory let SQL Server handle this • Disable write caching for the OS• Move the data and logs off the OS Disk preferably onto

separate drives• Use the volatile D: drive for tempdb storage• Use page compression to reduce IO

Page 26: Iaas, sql, rest and powershell

SQL High Availability

Virtual Machine

Virtual Machine

SQL Server Primary

SQL Server Secondary

Availability Set

Database mirroring available now in the preview

SQL 2012 AlwaysOn Feature using Windows Clustering available in the commercial VM release

Page 27: Iaas, sql, rest and powershell

Q&ASee http://blog.elastacloud.com or follow @azurecoder for details of using mirroring