Windows Azure Storage & Sql Azure
Upcoming SlideShare
Loading in...5
×
 

Windows Azure Storage & Sql Azure

on

  • 11,529 views

Windows Azure Storage & Sql Azure

Windows Azure Storage & Sql Azure

Statistics

Views

Total Views
11,529
Views on SlideShare
10,937
Embed Views
592

Actions

Likes
8
Downloads
307
Comments
1

22 Embeds 592

http://blog.maartenballiauw.be 280
http://www.joshholmes.com 166
http://www.slideshare.net 50
http://www.freelancephp.co.uk 43
http://www.blog.maartenballiauw.be 17
http://cartrackr.codeplex.com 5
http://www.azurehub.com 5
http://azurehub.com 4
http://www.nofluffjuststuff.com 4
http://uberconf.com 3
http://www.nfjsone.com 2
http://projectautomationexperience.com 2
http://therichwebexperience.com 2
http://webcache.googleusercontent.com 1
http://www.springone2gx.com 1
http://www.windowsazurehub.com 1
http://www.therichwebexperience.com 1
http://windowsazurehub.com 1
http://translate.googleusercontent.com 1
http://microsoft.realdolmenblogs.com 1
http://www.jumpincamp.com 1
http://www.slashdocs.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • http://eric.blob.core.windows.net/music/rock/rush/xanadu.mp3Blobs – Provide a simple interface for storing named files along with metadata for the fileTables – Provide structured storage. A Table is a set of entities, which contain a set of propertiesQueues – Provide reliable storage and delivery of messages for an applicationTab
  • Harvesting!
  • Use queues as a way of communicating w/ the backend worker rolesWRs call getmessage and pass timeoutTimeout value is importantExpiration time is important; message is marked in the queue as invisible; for duration of timeout it’s invisibleWhen we’re done processing, we call a message to remove the message through a deleteTh reason we do this is imagine we have a second worker role; if something goes wrong, once the timeout expires, the message becomes visible, and the next person to do a get message will get the message
  • The PartitionKey combined with the RowKey uniquely identifies an entity in a table.
  • 11:53Getting the all of dunnry’s post it fast because we’re selecting the entities by a partition keyGetting all of the posts after a certain is slow because we may have to traverse across multiple servers because we’re selecting entities that span partition keysA query without the partition key is really a scan
  • We have included this feature comparison table in anticipation of your likely questions about differences between using a relational database table as you may be currently doing with your SQL Server databases and the new Windows Azure Tables included in Windows Azure.
  • As I stated earlier, SQL Azure is based on SQL Server 2008. At this time it is only a subset of the features of the server product.My intention here is to convey the high level features that are supported and the ones that are not.SQL Azure will support most of the things we need… Tables, Index, Views, Stored Procedures, Triggers, and Constraints… in my book… that’s all the functionality that I need for most of my applications.There are some other adjunct technologies that ship as part of SQL Server 2008 such as SQL Reporting Services and Analysis Services which are not supported. The Service Broker is also not supported.
  • So let’s assume that we have designed our relational database with local developer and data modeling tools.We can begin our story then by assuming that we want to get our database deployed to the cloud.There are some tools that will expedite this process which I will show you later, but for now lets assume that we have scripted our database schema. We apply this script to SQL Azure which speaks native TDS.If you created your database through the SQL Azure Portal, then SQL Azure will have created one master database and three replicas of that database. If you create your database with the script the same will be true.These replicas are stored in different database centers from the master to provide redundancy and protection against geographical catastrophe.
  • Configuring our application to use SQL Azure storage instead of SQL Server is simply a matter of modifying the connection string in our application’s configuration file.When our application requests data, ADO.NET speaks to the TDS which directs our queries to the master database server. The master database server performs our query and returns the results to our application.
  • From our application’s point of view, there is only one SQL Azure database.As we make updates to our database, those updates are replicated to other copies stored in other data centers so that in the event that our database fails for any reason, the other databases will be standing by ready to take its place.
  • But what if that master database server fails for some reason?TDS is receives notification of the database failure and automatically redirects the call to the replica!The Azure Cloud Fabric is self-healing… and the details are outside the scope of this presentation; however, the fabric will get busy repairing itself like drones on a Borg mother ship… essentially with the objective of keeping three replicas online at a time.
  • I will demonstrate creating a SQL Azure account in session 3 where I will walk you through the entire process.For now I simply want to give you some background information to prepare you for our first demonstration.When we create our SQL Azure database server, we’ll be prompted for an Administrator’s name and a password.This username and password will be the granted a system administrator role that is similar to the “sa” account on a local SQL Server 2008 box. The account has permission to create and drop databases and database ownership authority in any databases that you create with this account.
  • After creating your SQL Azure database server, you will want to grant appropriate access through the SQL Azure firewall.SQL Azure provides a very simple and easy to maintain firewall. The firewall is so easy to use that it’s only going to get one slide in my deck!The firewall allows us to expose our database to Windows Azure services via a checkbox and to add ranges of IP addresses such as your home office and your business… or possibly the address of a 3rd party server hosting some application that needs data access.I’ll do a thorough demo of this feature in session 3…
  • When you created your SQL Azure database server, you supplied an administrator’s user name and password. I have named my user accordingly… to remind me of its power.The SQL Portal will offer you the ability to copy these credentials in connection string format to your clip board… tempting you into believing that you should just paste this into your configuration file.This is terrific for demos like mine… BUT you should NEVER, EVER do this…A database server system administrator password placed in a configuration file in clear text format… there has got to be something naive in the extreme going on here… and worse… no way to create non-sa-like users through the UI… you must script your database users and then apply the script to the database. And to anticipate your question… no… you can’t use SQL Server Management Studio to do this either.I will demo this as well in session 3… so hang tight…

Windows Azure Storage & Sql Azure Windows Azure Storage & Sql Azure Presentation Transcript

  • Windows Azure StorageSQL Azure
    Developing with Windows Azure storage & SQL Azure
    Maarten Balliauw
    http://blog.maartenballiauw.be
    http://twitter.com/maartenballiauw
    maarten@maartenballiauw.be
  • Whoam I?
    Maarten Balliauw
    Antwerp, Belgium
    www.realdolmen.com
    Focus on web
    ASP.NET, ASP.NET MVC, PHP, Azure, VSTS, …
    Special interest in interop
    PHPExcel, PHPLinq, PHPMEF, Windows Azure SDK for PHP, ...
    http://blog.maartenballiauw.be
    http://twitter.com/maartenballiauw
  • Agenda
    • Storage concepts
    • Windows Azure SDK for PHP
    • SQL Azure
  • Storage concepts
    Where can I store my stuff?
  • Windows Azure Data Storage
    Queue
    Blob
    Account
    Tables
    Drives
  • Azure Platform Data Storage Options
    Windows Azure Data Storage
    Blobs
    Unstructured data storage
    Tables
    Semi-structured or tabular data storage
    Queues
    Buffered delivery data storage
    Drives
    Durable NTFS volumes that Windows Azure applications can use. See: http://microsoftpdc.com/Sessions/SVC14
    SQL Azure
    Relational data storage
  • PHP + Cloud Storage
    Windows Azure Storage
    PHP
    Instance (web/worker)
    On-Premise
    VIP
    Load Balancer
    PHP App
    SQL Azure
    Windows Azure Platform
  • Windows Azure Data Storage
  • Windows Azure Data Storage
  • Windows Azure SDK for PHP
    A PHP porgramming model for Windows Azure Storage
  • PHP with Windows Azure Storage
    Windows Azure SDK for PHP at http://phpazure.codeplex.com
    PHP programming model for Windows Azure Storage
    Features
    PHP classes for Blobs, Tables & Queues
    Store PHP sessions in Table Storage
    File system wrapper for Blob Storage
  • Blob
    Container
    Entities
    Account
    Table
    http://<account>.blob.core.windows.net/<container>
    Messages
    Windows Azure Storage Concepts
    http://<account>.table.core.windows.net/<table>
    Queue
    http://<account>.queue.core.windows.net/<queue>
  • Windows Azure Blobs
    Unstructured data
    Scale massively
    At least 3 instances, 5 in optimal situation
    Can be used as CDN
    Can be mapped using a custom domain
  • Tools for connecting to blob storage
    CloudBerryLab Explorerhttp://www.cloudberrylab.com
    Azure Storage Explorerhttp://azurestorageexplorer.codeplex.com/
    Onlinehttp://myazurestorage.com / ftp://ftp.cloudapp.net
    Windows Azure tooling for Eclipse
  • Blobs Sample
    $blobStorage= new Microsoft_WindowsAzure_Storage_Blob();
    // Create
    if (!$blobStorage->containerExists($containerName))
    {
    $blobStorage->createContainer($containerName);
    $blobStorage->setContainerAcl($containerName,
    Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC);
    }
    // Store
    $blob = $blobStorage->putBlob($containerName, $blobName,
    $localFilename, $metadata);
    /* @var $blob Microsoft_WindowsAzure_Storage_BlobInstance */
  • Blobs Sample Cont…
    // Copy
    $result = $blobStorage->copyBlob(
    $containerName, $blobName, $containerName, $blob2Name);
    // Retrieve
    $tempStore= azure_getlocalresourcepath('tempstore');
    $tempPath= $tempStore. 'apos; . $imageId;
    $blobStorage->getBlob($containerName, $blobName, $tempPath);
    // Delete
    $result = $blobStorage->deleteBlob($containerName, $blobName);
    $result = $blobStorage->deleteContainer($containerName);
    http://phpazurecontrib.codeplex.com
  • Blob Stream Wrapper
    $blobStorage= new Microsoft_WindowsAzure_Storage_Blob();
    // Register:
    $blobStorage->registerStreamWrapper(); // registers azure://
    // or
    $blobStorage->registerStreamWrapper('blob://'); // use blob://
    // Use
    $fp= fopen('azure://mycontainer/myfile.txt', 'r');
    // ...
    fclose($fp);
  • Windows Azure Drive (a.k.a. Xdrive)
    Virtual NTFS volume that can be mounted
    .vhd format
    Use existing NTFS API’s
    Easier migration
    Stored on blob storage provides quick mount/unmount in other VM
  • Queue Workflow Concepts
    Windows Azure Queue Provides
    Guarantee delivery (two-step consumption)
    Worker Dequeues Message and mark it as Invisible
    Worker Deletes Message when finished processing it
    If Worker role crashes, message becomes visible for another Worker to process
    Doesn’t guarantee “only once” delivery
    Doesn’t guarantee ordering
    Best effort FIFO
    Worker Role
    Web Role
    Input Queue (Work Items)
    Worker Role
    Azure Queue
    Web Role
    Worker Role
    Web Role
    Worker Role
  • Azure Queues
    RemoveMessage
    GetMessage (Timeout)
    Worker Role
    PutMessage
    Queue
    Msg 1
    Msg 2
    Msg 2
    Msg 1
    Web Role
    Worker Role
    Worker Role
    Msg 3
    Msg 4
    Msg 2
  • Loosely Coupled Work with Queues
    Worker-Queue Model
    Load work in a queue
    Many workers consume the queue
    Input Queue (Work Items)
    Azure Queue
    Worker Role
    Web Role
    Worker Role
    Web Role
    Worker Role
    Web Role
    Worker Role
  • Queues
    $queueClient= new Microsoft_WindowsAzure_Storage_Queue();
    // Create
    $result = $queueClient->createQueue('imageQueue');
    // Delete
    $queueClient->deleteQueue('imageQueue');
    // Add message
    $queueClient->putMessage('imageQueue', $message, $ttl);
    // Retrieve Messages
    $messages = $queueClient->getMessages('imageQueue', 10);
    foreach($messages as $message) {
    // Do work here...
    $queueClient->deleteMessage('imageQueue', $message);
    }
  • Windows Azure Data Storage – Tables (Terms Part 1)
    Table
    Contains a set of entities.
    Entity (Row)
    Basic data items stored in a table.
    Property (Column)
    Single value in an entity.
    RowKey
    Unique ID of the entity within a partition
    Timestamp
    Time it was created
  • Windows Azure Data Storage – Tables (Terms Part 2)
    Partition
    Entities in a table with the same partition key
    PartitionKey
    Segments entities in to partitions to automatically distribute the table’s entities over many storage nodes.
    Sort Order
    There is a single index provided, where all entities in a table are sorted by PartitionKey and then RowKey
  • Key Example – Blog Posts
    Partition 1
    Partition 2
    Getting all of dunnry’s blog posts is fast
    Single partition
    Getting all posts after 2008-03-27 is slow
    Traverse all partitions
  • Table Sample
    $tableStorage= new Microsoft_WindowsAzure_Storage_Table(
    'table.core.windows.net', 'myaccount', 'myauthkey');
    // Create
    $result = $tableStorage->createTable($tableName);
    // List
    $result = $tableStorage->listTables();
    foreach($result as $table) {
    echo 'Table name is: ' . $table->Name . " ";
    }
    // Delete
    $tableStorage->deleteTable($tableName);
  • Tables with Entities
    // Structured entity
    class ImageEntityextends
    Microsoft_WindowsAzure_Storage_TableEntity
    {
    /**
    * @azure filename
    */
    public $filename;
    /**
    * @azure size Edm.Int64
    */
    public $size;
    }
    // Unstructured entity
    // Microsoft_WindowsAzure_Storage_DynamicTableEntity
  • Tables with Entities Cont…
    // Insert
    $image = new ImageEntity($partitionKey, $rowKey);
    $image->filename = $_FILES['imageUpload']['name'];
    $image->size = $_FILES['imageUpload']['size'];
    $image = $tableStorageClient->insertEntity($tableName, $image);
    // Retrieve
    $image = $tableStorage->retrieveEntityById($tableName,
    $partitionKey, $rowKey, 'ImageEntity');
    // Update
    $image->filename = 'newname.jpg';
    $result = $tableStorage->updateEntity($tableName, $image);
    // Delete
    $result = $tableStorage->deleteEntity($tableName, $image);
  • Table Queries
    // Filter condition
    $select = "filesizegt 1024 and PartitionKeyeq '$partitionKey'";
    // Or fluent interface
    $select = $tableStorage->select()->from($tableName)
    ->where('filesizegt 1024')
    ->andWhere('PartitionKeyeq ?', $partitionKey);
    // Run query
    $images = $tableStorage->storageClient->retrieveEntities(
    'testtable', $select, 'ImageEntity'
    );
    foreach($images as $image) {
    echo 'Name: ' . $image->filename . " ";
    }
  • Batching Operations
    // Start batch
    $batch = $tableStorage->startBatch();
    // Insert multiple
    $images = generateEntities();
    foreach($images as $image) {
    $tableStorage->insertEntity($tableName, $image);
    }
    // Commit
    $batch->commit();
  • Table session handler
    $sessionHandler
    = new Microsoft_WindowsAzure_SessionHandler($tableStorage);
    $sessionHandler->register();
    session_start();
    if (!isset($_SESSION['start'])) {
    $_SESSION['start'] = time();
    }
  • SQL Azure
    A relational database for the cloud
  • SQL Azure and Windows Azure Table Comparison
    SQL Azure Tables
    Windows Azure Tables
    Fully structured
    Strongly typed
    Relational(RDBMS)
    Highly scalable
    Semi-structured
    Loosely typed
    Non-Relational(Not RDBMS)
    Massively scalable
  • MySQL: Simple Configuration
    VIP
    Load Balancer
    Web Role
    MySQL
    Worker Role
  • MySQL in a Windows Azure Application
    Running MySQL in a worker role
    Copy MySQL to the worker role sub-directory
    Copy to read-write local storage
    Configure MySQL to listen on the right port
    Monitor MySQL health
    Consuming MySQL
    Discover IP address and port
    Normal access from then on
    Handle topology changes
  • Simple Configuration
    VIP
    Load Balancer
    MySQL
  • Replication
    VIP
    Load Balancer
    M
    S
    S
    MySQL
    MySQL
    MySQL
  • Windows Azure Drive with Hot Spare
    VIP
    Load Balancer
    MySQL
    MySQL
  • Windows Azure Drive with Hot Spare
    VIP
    Load Balancer
    MySQL
    MySQL
  • SQL Azure Features
    Supported
    Not supported
    Tables, Indexes, Views
    Stored Procedures
    Triggers
    Constraints
    Table Variables
    Temp Tables (#Name)
    Physical Server Access
    Catalog DDL
    Common Language Runtime
    Service Broker
    Reporting Services
    Analysis Services
    Distributed Transactions and Queries
  • SQL AzureDeployment
    Web Portal
    (API)
    DB Script
    SQL Azure
    TDS
  • SQL AzureAccessing databases
    Web Portal
    (API)
    Your App
    SQL Azure
    TDS
    Change Connection String
  • Database Replicas
    Single Database
    Multiple Replicas
    Replica 1
    Single Primary
    Replica 2
    DB
    Replica 3
  • SQL AzureDatabase Monitoring & Recovery
    Web Portal
    (API)
    !
    Your App
    SQL Azure
    TDS
  • SQL Azure Server Creation
  • SQL Azure Firewall Maintenance
    • Simple rules
    • Easy one-screen portal maintenance
  • SQL Azure Database Connection String
    An administrative user is created with the server
    User has system administrator permissions like “sa”
    Server=tcp:itte80vcfq.database.windows.net; Database=FabrikamAzureDB;User ID=SaPaulM;Password=myPassword;Trusted_Connection=False;Encrypt=True;
  • Migrating schema and data
    SQL Azure Migration Wizardhttp://sqlazuremw.codeplex.com
    SQL Azure Data Sync Tool for SQL Serverhttp://www.microsoft.com/windowsazure/developers/sqlazure/datasync/
    SQL Server Management Studio 2008 R2 November Community Technology Preview
  • PHP with SQL Azure
    SQL Server Driver for PHP @ http://sqlsrvphp.codeplex.com/
    Supports PHP access to SQL Azure
    Features
    Choose between SQL Server and SQL Azure by changing connection string
    Use from on-premises or in Windows Azure
  • Resources
    Learn more!
  • Resources
    Microsoft Windows Azure Interop
    http://www.microsoft.com/windowsazure/interop/
    Interop Bridges
    http://www.interoperabilitybridges.com/
  • More resources
    PHP
    http://www.windowsazure4e.org
    http://phpazure.codeplex.com/
    http://phpazurecontrib.codeplex.com/
    MySQL
    Windows Azure MySQL PHP Solution Accelerator
    http://code.msdn.microsoft.com/winazuremysqlphp
  • Questions?
    More information?
    Contact me
    http://phpazure.codeplex.com
    http://blog.maartenballiauw.be
    maarten@maartenballiauw.be
    http://twitter.com/maartenballiauw
    Thankyouforwatching!